combobox : select using an item text

BlitzMax Forums/BlitzMax GUI Programming/combobox : select using an item text

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This is probably how I would do it, though I don't know if it's the best way:
Strict 

Local window:TGadget
Local combobox:TGadget
Local textfield:TGadget
Local button:TGadget

window=CreateWindow("My Window",30,20,200,200)

combobox=CreateComboBox(4,4,120,22,window)
AddGadgetItem combobox,"Short"
AddGadgetItem combobox,"Medium"
AddGadgetItem combobox,"Fat",True
AddGadgetItem combobox,"Humungous"

textfield=CreateTextField(4,40,100,24,window)
button=CreateButton("Button",4,70,100,24,window)

While WaitEvent()
	Select EventID()
		Case EVENT_GADGETACTION
			If EventSource() = button
				Local i
				For i=1 To CountGadgetItems(combobox)
					If GadgetItemText(combobox,i-1) = GadgetText(textfield) SelectGadgetItem(combobox,i-1)
				Next
			EndIf
		Case EVENT_WINDOWCLOSE
			End
	End Select
Wend