Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ComboBox and ListBox
Message
 
To
27/11/2001 16:29:20
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00586449
Message ID:
00586719
Views:
17
>I don't see the itemdata property. Where is it? I looked under the main control and under the items property. Also, does the listbox or combobox have to be bound to the dataset to use this itemdata property? Thanks for the help.

This is copied from the VB help file:

ItemData Property Example
This example fills a ListBox control with employee names and fills the ItemData property array with employee numbers using the NewIndex property to keep the numbers synchronized with the sorted list. A Label control displays the name and number of an item when the user makes a selection. To try this example, paste the code into the Declarations section of a form that contains a ListBox and a Label. Set the Sorted property for the ListBox to True, and then press F5 and click the ListBox.

Private Sub Form_Load ()
' Fill List1 and ItemData array with
' corresponding items in sorted order.
List1.AddItem "Judy Phelps"
List1.ItemData(List1.NewIndex) = 42310
List1.AddItem "Chien Lieu"
List1.ItemData(List1.NewIndex) = 52855
List1.AddItem "Mauro Sorrento"
List1.ItemData(List1.NewIndex) = 64932
List1.AddItem "Cynthia Bennet"
List1.ItemData(List1.NewIndex) = 39227
End Sub

Private Sub List1_Click ()
' Append the employee number and the employee name.
Msg = List1.ItemData(List1.ListIndex) & " "
Msg = Msg & List1.List(List1.ListIndex)
Label1.Caption = Msg
End Sub
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform