Results 1 to 6 of 6

Thread: List.ItemData and NewIndex

  1. #1

    Thread Starter
    Lively Member ranma_at's Avatar
    Join Date
    Oct 2002
    Location
    @ Home
    Posts
    72

    Exclamation List.ItemData and NewIndex

    Hello,

    does anyone know how to replace the List properties
    List.itemdata and List.newindex with the ones from a Listview

    I have a list and I want to replace it with a listview, but i cant cause my list uses:

    frmMain.List1.ItemData(frmMain.List1.NewIndex) = xx

    how would this line be with a listview ?
    I tried alot but didnt found anything
    thanks...

  2. #2
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    VB Code:
    1. Dim lvwItem as listitem
    2.  
    3.  Set lvwItem = ListView1.ListItems.Add(,,[Your Text])
    4.  lvwItem.Tag = [Itemdata]
    5.  
    6.  
    7. 'OR
    8.  
    9.  Set lvwItem = ListView1.ListItems.Add( , Cstr([ItemData]) & "K", [Your Text])
    10.  
    11. 'With this way you can:
    12.  
    13. Set lvwItem = listView1.ListItems.Item(Cstr([ItemData]) & "K")
    14.  
    15. :D

    Woka

  3. #3

    Thread Starter
    Lively Member ranma_at's Avatar
    Join Date
    Oct 2002
    Location
    @ Home
    Posts
    72

    oh thanks

    BTW when you post code here, how do you make it look like that i mean i know how to do the 2 lines above and under the code but not the coloring ...

    but thanks :-)

  4. #4

  5. #5
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    In a listbox, you can store two possible values per entry: one in the "List" array, which is what the user sees, and one in the "ItemData" array (a number you can store "behind the scenes").
    In a ListView, for each ListItem, you have the Text property, as well as any number of SubItems. The number of SubItems is dependent upon how many ColumnHeaders you have defined.

    Assuming you have at least two ColumnHeaders defined, you can convert:
    List1.AddItem "Bob"
    List1.ItemData(List1.NewIndex) = 12345
    to:
    Dim objLI As ListItem
    Set objLI = ListView1.ListItems.Add(, , "Bob")
    objLI.SubItems(1) = "12345"

    Hope that helps.
    "It's cold gin time again ..."

    Check out my website here.

  6. #6

    Thread Starter
    Lively Member ranma_at's Avatar
    Join Date
    Oct 2002
    Location
    @ Home
    Posts
    72
    exactly what i needed - thanks

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