DComboBox
Methods
number DComboBox:AddChoice( string value, any data = nil, boolean select = false, string icon = "nil" )
Adds a choice to the combo box.
DComboBox:ChooseOption( string value, number index )
Selects a combo box option by its index and changes the text displayed at the top of the combo box.
DComboBox:ChooseOptionID( number index )
Selects an option within a combo box based on its table index.
DComboBox:Clear()
Clears the combo box's text value, choices, and data values.
DComboBox:CloseMenu()
Closes the combo box menu. Called when the combo box is clicked while open.
string DComboBox:GetOptionTextByData( string data )
Returns an option's text based on the given data.
boolean DComboBox:GetSortItems()
Returns an whether the items in the dropdown will be alphabetically sorted or not.
See DComboBox:SetSortItems.
DComboBox:OnSelect( number index, string value, any data )
Called when an option in the combo box is selected. This function does nothing by itself, you're supposed to overwrite it.
DComboBox:OpenMenu()
Opens the combo box drop down menu. Called when the combo box is clicked.
DComboBox:SetSortItems( boolean sort )
Sets whether or not the items should be sorted alphabetically in the dropdown menu of the DComboBox. If set to false, items will appear in the order they were added by DComboBox:AddChoice calls.
This is enabled by default.
Example
Creates a Combo Box.
local frame = vgui.Create( "DFrame" )
frame:SetSize( 300, 250 )
frame:Center()
frame:MakePopup()
local DComboBox = vgui.Create( "DComboBox", frame )
DComboBox:SetPos( 5, 30 )
DComboBox:SetSize( 100, 20 )
DComboBox:SetValue( "options" )
DComboBox:AddChoice( "option A" )
DComboBox:AddChoice( "option B" )
DComboBox:AddChoice( "option C" )
DComboBox.OnSelect = function( self, index, value )
print( value .." was selected at index " .. index )
end
Output:
option B was selected at index 2



Example
Create a Combo Box with all players