-
I remember being able somehow to store extra data for a item in a listbox but I cant remember how to do it. Like say you have list1.additem "Whatever" and you want to store something for whatever like a definition. So when they click on whatever it brings up that definition stored in the thing. On a few controls ive used they called it the key but the listbox doesnt have one of these that I can find..?? Any help?
-
Code:
list1.itemdata(1)=150
-
You could also use a arrays to store how much data you want for each selection
Code:
Dim ExtraData() As String
-
The listbox specifically doesn't have the ability to add extra data...
The combobox, listview and most grids (as well as collections) DO have this ability.
Your choices are simple.
1. Use a listview that only has a single column.
2. Create a collection to match the listbox
Code:
Dim cList as New Collection
list1.additem "display"
cList.add "display", "keyvalue"
Sub list1_click()
msgbox "Extra Information " & cList(list1.listindex).key
End Sub
You just have to make sure both the listbox and the collection are kept in sync