Garry's Mod Wiki

DComboBox:SetValue

  DComboBox:SetValue( string value )

Description

Sets the text shown in the combo box when the menu is not collapsed.

Arguments

1 string value
The text in the DComboBox.

Example

A simple feedback combo box which has the value set to a thank you message once a choice is clicked.

BGPanel = vgui.Create("DPanel") BGPanel:SetPos(20, 20) BGPanel:SetSize(200, 30) local cbox = vgui.Create("DComboBox", BGPanel) cbox:SetPos(5, 5) cbox:SetSize(190, 20) cbox:SetValue("What do you think of this server?") -- Responses cbox:AddChoice("It's the best server of all time!") cbox:AddChoice("It's pretty good.") cbox:AddChoice("It's okay.") cbox:AddChoice("It's not that good.") cbox:AddChoice("Don't bother me with this.") function cbox:OnSelect(index, value, data) -- Clear combo box and set a thank you message self:Clear() self:SetText("Thank you for your feedback!") -- Here you would send the feedback to the server using a net message -- The choice is stored in the 'data' variable end
Output: