[Gambas-user] Help on Listbox

Lucian Teofanescu dentapro at ...438...
Sat Apr 24 10:48:38 CEST 2004


Hi all, thank you for answering my previous question.

Here is a second one:
I need to fill a listbox with customers names from a table but I also need to store in the listbox the ID of the customer from the same table, to use it for performing future select queries on other tables. In VB6 (old habits ;-)) I'm doing like this:

'fill the listbox List1 with customers names from recordset rsCustomers
Do While Not rsCustomers.EOF
    List1.AddItem rsCustomers!Name
    List1.ItemData(List1.NewIndex) = rsCustomers!ID
    rsCustomers.MoveNext
Loop

Private Sub List1_Click()
    MsgBox List1.ItemData(List1.ListIndex) ' Show the ItemData property of the current clicked item
End Sub


In Gambas I'm doing like this:

'fill the listbox ListBox1 customers names from resultset rsCustomers
Do While rsCustomers.Available
    ListBox1.Add rsCustomers!Name
    rsCustomers.MoveNext
Loop

Where to store the ID field - I mean what property of the listbox to use (an equivalent for the ItemData property in VB)? If there isn't such a property maybe it will be available in future versions of Gambas. But how to provide similar functionality until then?
The only think I have in mind is to concatenate the Name and ID fields (something like "Lucian Teofanescu #2905") and fill the list with this string. When I need to retrieve the ID of the customer I can extract the part after # and convert it to an integer in order to perform my queries. Is there an easier way?

Thank you for your time
Lucian Teofanescu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20040424/0a6e8d65/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SecurityCheck.txt
Type: text/ignore
Size: 1064 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20040424/0a6e8d65/attachment.bin>


More information about the User mailing list