Results 1 to 10 of 10

Thread: Listview and index

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    259

    Listview and index

    Dear Friends,

    I have a listview control. When i click on a record (full fow select) i need to know the index of the record i have selected.

    With the same listview i have checkbox, when i click on command_1 (for exaple) i need to know the indexes of the checked records.

    how can i resolv that problem?

    Best regards,

  2. #2
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Getting index is simple:

    Private Sub ListView1_ItemClick(ByVal Item As MSComctlLib.ListItem)
    Dim intIndex As Integer

    intIndex = Item.Index

    End Sub

    But what do you mean by saying "With the same listview i have checkbox" ?

    Roy

  3. #3
    New Member
    Join Date
    May 2001
    Location
    The Rock
    Posts
    13
    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim li As ListItem
    3.     Dim checkedCol As Collection
    4.     Set checkedCol = New Collection
    5.    
    6.     'Where lvw is your listview.
    7.    
    8.     For Each li In lvw.ListItems
    9.         If li.Checked = True Then
    10.             'add its key to a collection
    11.             checkedCol.Add li.Index
    12.             Debug.Print li.Index
    13.         End If
    14.     Next
    15.     'CheckedCol now contains a list of the
    16.     'indexes of all the items that were checked.
    17.    
    18. End Sub

    Try this.

  4. #4
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    smokingjoe,
    I'd rather wait untill he responds then give him a sample loop.

  5. #5
    New Member
    Join Date
    May 2001
    Location
    The Rock
    Posts
    13
    still waiting!

  6. #6
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    so what?!

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    259
    Hey many thanks for the reply . I am verry happy now . I could not respond because i wasn't home.

    thanks

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    259

  9. #9
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Resolve what? Diddn't you get what you were looking for? It looks to me that smokinjoe gave a very nice example on how to follow mouse pointer. If you still have a problem with that issue then reply, if not then mark that tread as Resolved.

    Roy

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    259
    IROY55 yes smokinjoe have give me a very nice piece of code but when i hade post this...

    Maybee you can resolv this to?
    http://www.vbforums.com/showthread....threadid=196412

    ...smokinjoe was still writing the code for me so i had not any code. Now i have and this post is closed.

    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