guiGridListGetSelectedItem
Client-side
Server-side
Shared
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
This function returns the row and column indexes of the selected item in a grid list. First selected row and column is (0, 0).
OOP Syntax Help! I don't understand this!
- Method: guigridlist:getSelectedItem(...)
Syntax
int, int guiGridListGetSelectedItem ( element gridList )Required Arguments
- gridList: the grid list you want to know the selected row index of
Returns
- int: value1
- int: value2
Returns the row and column indexes of the selected item if the specified grid list is valid and has a selected item, (-1, -1) if no item is selected, false otherwise.
Code Examples
shared
This code creates a grid list and fills it with the names of the connected players. When the user selects an item, its text (the player name) will be output in the chat box.
addEventHandler('onClientResourceStart', resourceRoot, function() local playerList = guiCreateGridList(0.8, 0.1, 0.15, 0.6, true)
-- Create a players column in the list local column = guiGridListAddColumn(playerList, 'Player', 0.85)
-- If the column has been created, fill it with players if not column then return end
for id, playeritem in ipairs(getElementsByType('player')) do local row = guiGridListAddRow ( playerList ) guiGridListSetItemText(playerList, row, column, getPlayerName(playeritem), false, false) end
addEventHandler('onClientGUIClick', playerList, function() local row, column = guiGridListGetSelectedItem(playerList) outputChatBox(guiGridListGetItemText(playerList, row, column)) end)endSee Also
GUI Functions
- getChatboxCharacterLimit
- getChatboxLayout
- guiBlur
- guiBringToFront
- guiCheckBoxGetSelected
- guiCheckBoxSetSelected
- guiComboBoxAddItem
- guiComboBoxClear
- guiComboBoxGetItemCount
- guiComboBoxGetItemText
- guiComboBoxGetSelected
- guiComboBoxIsOpen
- guiComboBoxRemoveItem
- guiComboBoxSetItemText
- guiComboBoxSetOpen
- guiComboBoxSetSelected
- guiCreateBrowser
- guiCreateButton
- guiCreateCheckBox
- guiCreateComboBox
- guiCreateEdit
- guiCreateFont
- guiCreateGridList
- guiCreateLabel
- guiCreateMemo
- guiCreateProgressBar
- guiCreateRadioButton
- guiCreateScrollBar
- guiCreateScrollPane
- guiCreateStaticImage
- guiCreateTab
- guiCreateTabPanel
- guiCreateWindow
- guiDeleteTab
- guiEditGetCaretIndex
- guiEditGetMaxLength
- guiEditIsMasked
- guiEditIsReadOnly
- guiEditSetCaretIndex
- guiEditSetMasked
- guiEditSetMaxLength
- guiEditSetReadOnly
- guiFocus
- guiGetAlpha
- guiGetBrowser
- guiGetCursorType
- guiGetEnabled
- guiGetFont
- guiGetInputEnabled
- guiGetInputMode
- guiGetPosition
- guiGetProperties
- guiGetProperty
- guiGetScreenSize
- guiGetSelectedTab
- guiGetSize
- guiGetText
- guiGetVisible
- guiGridListAddColumn
- guiGridListAddRow
- guiGridListAutoSizeColumn
- guiGridListClear
- guiGridListGetColumnCount
- guiGridListGetColumnTitle
- guiGridListGetColumnWidth
- guiGridListGetHorizontalScrollPosition
- guiGridListGetItemColor
- guiGridListGetItemData
- guiGridListGetItemText
- guiGridListGetRowCount
- guiGridListGetSelectedCount
- guiGridListGetSelectedItem
- guiGridListGetSelectedItems
- guiGridListGetSelectionMode
- guiGridListGetVerticalScrollPosition
- guiGridListInsertRowAfter
- guiGridListIsSortingEnabled
- guiGridListRemoveColumn
- guiGridListRemoveRow
- guiGridListSetColumnTitle
- guiGridListSetColumnWidth
- guiGridListSetHorizontalScrollPosition
- guiGridListSetItemColor
- guiGridListSetItemData
- guiGridListSetItemText
- guiGridListSetScrollBars
- guiGridListSetSelectedItem
- guiGridListSetSelectionMode
- guiGridListSetSortingEnabled
- guiGridListSetVerticalScrollPosition
- guiLabelGetColor
- guiLabelGetFontHeight
- guiLabelGetTextExtent
- guiLabelSetColor
- guiLabelSetHorizontalAlign
- guiLabelSetVerticalAlign
- guiMemoGetCaretIndex
- guiMemoGetVerticalScrollPosition
- guiMemoIsReadOnly
- guiMemoSetCaretIndex
- guiMemoSetReadOnly
- guiMemoSetVerticalScrollPosition
- guiMoveToBack
- guiProgressBarGetProgress
- guiProgressBarSetProgress
- guiRadioButtonGetSelected
- guiRadioButtonSetSelected
- guiScrollBarGetScrollPosition
- guiScrollBarSetScrollPosition
- guiScrollPaneGetHorizontalScrollPosition
- guiScrollPaneGetVerticalScrollPosition
- guiScrollPaneSetHorizontalScrollPosition
- guiScrollPaneSetScrollBars
- guiScrollPaneSetVerticalScrollPosition
- guiSetAlpha
- guiSetEnabled
- guiSetFont
- guiSetInputEnabled
- guiSetInputMode
- guiSetPosition
- guiSetProperty
- guiSetSelectedTab
- guiSetSize
- guiSetText
- guiSetVisible
- guiStaticImageGetNativeSize
- guiStaticImageLoadImage
- guiWindowIsMovable
- guiWindowIsSizable
- guiWindowSetMovable
- guiWindowSetSizable
- isChatBoxInputActive
- isConsoleActive
- isDebugViewActive
- isMainMenuActive
- isMTAWindowActive
- isTransferBoxActive
- setChatboxCharacterLimit
- setDebugViewActive