Results 1 to 5 of 5

Thread: checked listview problem

  1. #1
    PORRASTAR
    Guest

    checked listview problem

    I have a listview that I have set to have checkboxes. I need to see if a user has ticked any of the checkboxes.. What is the code to do this?

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Use the Checked property of a ListView item
    VB Code:
    1. Dim itm As ListItem
    2.  
    3. For Each itm In ListView1.ListItems
    4.     If itm.Checked = True Then
    5.         Debug.Print itm.Text & " is checked"
    6.     End If
    7. Next
    Best regards

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Dim i As Long
    2. For i = ListView1.ListItems.Count To 0 Step -1
    3.   If  Listview1.SelectedItem.Selected(i) = True Then Exit For
    4.       'if just one item is checked, then it stops
    5.   Else
    6.       'it went through the entire ListView and didn't find anything selected
    7.   End If
    8. Next

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Hmmm...Joacim types faster than I do

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Well, the selected property can be False even if you have checked one item.
    To control the check boxes go with the Checked property.

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