Garry's Mod Wiki

DComboBox

Description

A field with multiple selectable values.

Parent

Derives from DButton.

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!

Example

Create a Combo Box with all players

local comboBox = vgui.Create("DComboBox") comboBox:SetPos(5, 5) comboBox:SetSize(100, 20) comboBox:SetValue("All Players") comboBox.OnSelect = function( _, _, value) print(value.." was selected!") end for k,v in pairs(player.GetAll()) do comboBox:AddChoice(v:Name()) end

Page Links


Special Pages


Wikis

?

Render Time: 22ms

DB GetPage 2
Generate Html 2
SaveChanges (1) 8
Render Body 0
Render Sidebar 7