HELP retrieving current selected text from a DComboBox

Hey guys I am back with my very annoying questions.

I was wondering how would one get text from a DComboBox



	HMCombo = vgui.Create( "DComboBox", HMPanel )
	HMCombo:SetText( HMComboP[1] )
	HMCombo:SetSize( HMComboP[2], HMComboP[3] )
	HMCombo:SetPos( HMComboP[4], HMComboP[5] )
	HMCombo:AddChoice( "$200" )
	HMCombo:AddChoice( "$700" )
	HMCombo:AddChoice( "$1500" )
	HMCombo.OnSelect = function( panel, index, value, data )
	    print( "I want to get the text from the selected choice" )	
	end	


An example I found used the arg data like this
print ( data…" was selected." )

Though there is an error trying to retrieve something from data

It seems as though you have 1 too many arguments…

index, value, data are the arguments, data is the text.

Here are a few examples I’ve done:

[lua] self._lightang = vgui.Create( “DComboBox” , self )
self._lightang:SetValue( “Light Angle” )
self._lightang:SetPos( 110 , 5 )
self._lightang:SetSize( 100, 20 )
for k, v in pairs( ANGLES ) do
self._lightang:AddChoice( k )
end
self._lightang.OnSelect = function( index, value, data )
if ( !self._workingobject ) then return; end
self._workingobject.ang = ANGLES[ self._lightang:GetValue( ) ] – Here I use GetValue( ) on the actual DComboBox element
self:UpdateList( )
end[/lua]

and

And using a custom constructor function, the function( index, value, data ) is the custom onselect callback.
[lua] self.bonesIndex = index;
self:AddComboBox( index, self, offset, “Bones”, BONELIST[“ValveBiped.Bip01”], function( index, value, data )
if ( !DEBUG_HOLSTERED_WEAPONS_TABLE ) then return; end;
self.SelectedHS.bone = data; – Here I reference data, the third argument, on a callback and this returns the textual bone-name in this instance
end ) offset = offset + self._sheetList[ index ]:GetTall( ) + 5; index = index + 1;[/lua]

Thanks for your reply, I appreciate your response. This worked for me, and I cannot believe I didn’t think of this before. Anyways thanks you so much.