[Gambas-user] Automatic selection in a listbox

Fabricio Santos gambas at ...1229...
Fri Dec 2 00:06:41 CET 2005


On Thu, 2005-12-01 at 17:53 +0100, Felice Cafarelli wrote:
> 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

I am not really sure what you are trying to achieve with the above piece
of code. But I would scrap the whole thing and do this:

rData.MoveFirst
FOR EACH rData
   lstUsers.Add(rData!user)
NEXT
lstUsers.Index = 0

I have not tested this but this did populate the list and showed the
first item as selected:

ListBox1.Add("Item 1")
ListBox1.Add("Item 2")
ListBox1.Add("Item 3")
ListBox1.Index = 0





More information about the User mailing list