Results 1 to 4 of 4

Thread: Storing extra item specific data in a listbox

  1. #1
    Guest

    Lightbulb

    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?

  2. #2
    Lively Member
    Join Date
    Jun 2000
    Posts
    82
    Code:
    list1.itemdata(1)=150

  3. #3
    Hyperactive Member
    Join Date
    Dec 1999
    Posts
    321
    You could also use a arrays to store how much data you want for each selection

    Code:
    Dim ExtraData() As String
    Signed, Rodik ([email protected])
    Programmer,usesVB6ED
    ===========================
    Copyright©RodikCo,2002.

    Dont mind this signature ;] Its old

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width