[Gambas-user] Automatic selection in a listbox

Felice Cafarelli felixcafarelli at ...1176...
Thu Dec 1 17:53:51 CET 2005


Hi all, I had a problem with a listbox in gambas1.0.13: 
I populate dinamically (values from db) a listbox, and I want to automatically 
select the first value in the list after the population. I tried with the 
property INDEX, but I got only '-1' indexes, so i cannot distinguish the 
first item in the list. What can i do?
I post here the code:

FOR i = 1 TO rNumber
    lstUsers.Add(rData!user & "(" & lstUsers.Index & ")")
    IF lstUsers.Index = 0 THEN
      lstUsers.SetFocus
      lstUsers.Current.Selected
    ENDIF
    rData.MoveNext
  NEXT

Result is this list

Bob(-1)
Simon(-1)
Teddy(-1)

So I want Bob to be automatically selected... any idea?
Cheers
Felix




More information about the User mailing list