weirddemon
asked on
Get ListViewItem Checked state by Index in VB .NET
I've been trying to commit an action based on the Checked Index of that item. I've tried a bunch of different ways and I've come up with nothing so far.
Couple of things first:
I cannot use the ListViews events. I must be able to determine the Checked state from a button's event.
Again, I need to check a specific index (0-4) and then commit an action based on that. The following is an example that I've tried. More importantly, it will give you a better idea of what I need:
If ListView1.CheckedIndices(0 ) = True Then
'Checked
Else
'Not checked
End If
Couple of things first:
I cannot use the ListViews events. I must be able to determine the Checked state from a button's event.
Again, I need to check a specific index (0-4) and then commit an action based on that. The following is an example that I've tried. More importantly, it will give you a better idea of what I need:
If ListView1.CheckedIndices(0
'Checked
Else
'Not checked
End If
ASKER
Hawkvalley,
How does that apply at all?
How does that apply at all?
For a start, if no items are checked, ListView1.CheckedIndices will return an empty collection, so you can first check that there are indeed some items checked in the listview....
If ListView1.CheckedIndices.C ount > 0 Then
'there is at least 1 item checked
Else
'there are no items checked
End If
Wayne
If ListView1.CheckedIndices.C
'there is at least 1 item checked
Else
'there are no items checked
End If
Wayne
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Webtubbs.
I thought I had tried something like before and it gave me an error, but it appears to be working now.
Thanks
I thought I had tried something like before and it gave me an error, but it appears to be working now.
Thanks
Case 0
'something
Case 1
'something
Case 2
'something
Case 3
'something
Case 4
'something
End Select