Groups | Blog | Home
all groups > vb.net controls > december 2005 >

vb.net controls : Adding items with value/text to listbox


eagle
12/21/2005 2:22:04 PM
How can I add an item to a listbox so that the item has a value and a text?
I have a listbox that gets data from a datasource. The user clicks an item
and adds it to the 2nd listbox, in order to select the items they want. I
need the value and text (e.g., Client ID & ClientName) of each item the user
has moved to the second list.

lst2.items.add(???)

Thanks for your help.

Alec MacLean
1/29/2006 5:33:22 PM
You'll need to add the item pair as an object to the listbox.

One way is to create a class type with the ID and Name as properties.

When you then need to read back the value pair, you cast the selected item
back to the class type and access its properties normally, e.g. ClientID.

Al

[quoted text, click to view]

AddThis Social Bookmark Button