DComboBox.GetSelectedItems

From GMod Wiki

Jump to: navigation, search
Function
Syntax DComboBox:GetSelectedItems( )
Description:
Returns a table of the selected items in the combo box.
Returns: Table
In Object: DComboBox
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=DComboBox.GetSelectedItems]DComboBox.GetSelectedItems [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionGets the value of the first selected item in the returned table.
Used onNewerClient.png
Code
	 local Box = vgui.Create("DComboBox", Frame )
	     Box:AddItem( "Glass of Tea" )
	     Box:AddItem( "Some Random Animal" )
             Box:AddItem( "Another Item Here" )
             Box:SelectByName( "Glass of Tea" )
 
         print( Box:GetSelectedItems()[1]:GetValue() )
 
OutputThis makes a combo box with 3 items in it, then selects the first one. Using GetSelectedItems, and indexing the table it returns with the first value, we are able to print the value of the first selected item: in this case, "Glass of Tea."
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox