Garry's Mod Wiki

DForm:ComboBox

  Panel, Panel DForm:ComboBox( string title, string convar )

Description

Adds a DComboBox onto the DForm

Arguments

1 string title
Text to the left of the combo box
2 string convar
Console variable to change when the user selects something from the dropdown.

Returns

1 Panel
The created DComboBox
2 Panel
The created DLabel

Example

local frame = vgui.Create( "DFrame" ) frame:SetSize( ScrW() / 2, ScrH() / 2 ) frame:MakePopup() local form = frame:Add("DForm") form:Dock( FILL ) form:DockMargin( 5, 5, 5, 5 ) local combobox, label = form:ComboBox( "test", "sv_accelerate" ) combobox:AddChoice( "10" ) -- 10 will be used as convar value combobox:AddChoice( "1000", 100 ) -- 100 will be used as convar value