Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double click on ListView

Status
Not open for further replies.

andrey

Programmer
Jun 23, 2000
24
IL
There is a DblClick event for ListView control, but there is not DblClick event for it's ListItem. How can I define that DblClick event occures exactly when I make double click on ListItem and not on blank space of control?
 
What you need to do is:



Dim i As Long
Dim upper As Long

upper = lsv.ListItems.Count 'lsv is the name of the listview control

'The code below finds the selected item
'loops through each of the items till it finds a selected item, then the code in the if statement is executed..

For i = 1 To upper
If lsv.ListItems(i).Selected = True Then
'place code here that needs to be processed when an item is double clicked
Exit For
End If
Next i

Troy Williams B.Eng.
fenris@hotmail.com

 
Or you could use lsv.SelectedItem this wouldn't require the loop then.
 
But I DO NOT want to use the selected item!
OK, this is the code I use:
1. In the General section
Private lst As ListItem
2. In the MouseMove event
Set lst = lv.HitTest(x , y)'lv - the ListView control
3. In The DoubleClick event
If Not lst is Nothing Then
'My code here
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top