Getting the imageindex of a listview item?

bjwade62

Centurion
Joined
Oct 31, 2003
Messages
104
Does anyone know how to get the imageindex of a listview item? I can get if I dim a variable and put it inside a For Each loop. I don't want it to run through a loop since I already know which item is selected.

Here's what I'm trying to do. It doesn't work.
Visual Basic:
Dim ListItem As ListViewItem
If Button.MouseButtons = Windows.Forms.MouseButtons.Right And ListItem.ImageIndex = 5 Then
 
What are you looking for, specifically? The ImageIndex of the selected ListViewItem?

Does this help?
Visual Basic:
'If user clicked with right mouse button
' and there is one and only one item selected
' and that item has an image index of five then...
If e.Button = Windows.Forms.MouseButtons.Right _
    AndAlso ListView1.SelectedItems.Count = 1 _
    AndAlso ListView1.SelectedItems(0).ImageIndex = 5 Then
 
    'Like, do things, and stuff...
End If
 
That's exactly what I wanted. Thanks!

marble_eater said:
What are you looking for, specifically? The ImageIndex of the selected ListViewItem?

Does this help?
Visual Basic:
'If user clicked with right mouse button
' and there is one and only one item selected
' and that item has an image index of five then...
If e.Button = Windows.Forms.MouseButtons.Right _
    AndAlso ListView1.SelectedItems.Count = 1 _
    AndAlso ListView1.SelectedItems(0).ImageIndex = 5 Then
 
    'Like, do things, and stuff...
End If
 
Back
Top