ComboBox problem.

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by DemonHell.

I`ve searched the forums, found lots of threads about problems with the Combobox gadget, but not the one I`m having :((

Basically, I`ve got a combobox in a window, and I want to be able to read each of the items that`s been added to the list.

But using the snippet below, doesn`t return anything except an empty string :cry:

items=CountGadgetItems(#MyCombo)
if items
for a=0 to items-1
debug str(a)+":"+getgadgetitemtext(#MyCombo,a,0)
next
endif
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Manolo.

See the next code:

items=CountGadgetItems(#MyCombo)
If items
For a=0 To items
SetGadgetState(#MyCombo,a); <---------------------very important
Debug Str(a)+":"+GetGadgetItemText(#MyCombo,a,0)
Next
EndIf

Regards,
Manolo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by DemonHell.
Originally posted by Manolo
SetGadgetState(#MyCombo,a); <---------------------very important
Debug Str(a)+":"+GetGadgetItemText(#MyCombo,a,0)
Ta Manolo, it still didn`t work, but you pointed me in the right direction.

I found the GetGadgetItemText(#MyCombo,a,0) was still returning an empty string..
Tried the tip from another ComboBox thread on here of using the API call GetWindowText_(GadgetID(#MyComboBox),gadtext$,255) instead of the GetGadgetItemText, and it worked..WOOHOO.

Maybe this is (another?) bug in the combobox??
And why should we need to use SetGadgetState() to select a list item in the ComboBox when the GetGadgetItemText is meant to select it for us?
Post Reply