|
-
Mar 17th, 2005, 04:48 PM
#1
Thread Starter
Hyperactive Member
ListView
With theI am using the ListView control to display some files. How can I make them open by double-clicking them? The problem is not with opening them, but rather with detecting the double-click event.
There is a double-click event for ListView, but it occurs when the control itself is double-clicked, not when individual items are clicked by the user. What should I do?
I tried setting up a timer and seeing if the user clicks twice during a specific amount of ms, but it didn't work and is too un-professional 
What should I do?
Ash Nazg durbatuluk, Ash Nazg gimbatul, Ash Nazg tharkathuluk, Agh barzum-ishi krimpatul.
-
Mar 17th, 2005, 05:10 PM
#2
Re: ListView
VB Code:
Private Sub ListView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Static t As Single
Static itm As ListItem
'ok the following test could be done better
'You could use GetTickCount istead of the Timer function
'and you can use the APIs to get the correct double click speed
If Timer - t < 0.5 Then
If Not ListView1.HitTest(x, y) Is Nothing Then
If Not itm Is Nothing Then
If itm Is ListView1.HitTest(x, y) Then
'Double Click has occured!
MsgBox "Double Click"
End If
End If
End If
End If
t = Timer
Set itm = ListView1.HitTest(x, y)
End Sub
-
Mar 17th, 2005, 05:50 PM
#3
Re: ListView
What's wrong with doing it like this?
VB Code:
Private Sub ListView1_DblClick()
MsgBox ListView1.SelectedItem
End Sub
-
Mar 17th, 2005, 06:00 PM
#4
Re: ListView
 Originally Posted by baja_yu
What's wrong with doing it like this?
VB Code:
Private Sub ListView1_DblClick()
MsgBox ListView1.SelectedItem
End Sub
Nothing but the fact that you might not have double clicked on the selected item. You can double click outside of any item and the DblClick event will fire. My code ensures you double click on a specific item.
-
Mar 17th, 2005, 06:04 PM
#5
Thread Starter
Hyperactive Member
Ash Nazg durbatuluk, Ash Nazg gimbatul, Ash Nazg tharkathuluk, Agh barzum-ishi krimpatul.
-
Mar 17th, 2005, 06:06 PM
#6
Re: ListView
 Originally Posted by Joacim Andersson
Nothing but the fact that you might not have double clicked on the selected item. You can double click outside of any item and the DblClick event will fire. My code ensures you double click on a specific item.
Yes, but still, when you double click it, it will select it on the first click, and the second one will fire the doubleclick event.
The only downside I think is that if you doubleclick on empty space it will tirgger the code.
-
Mar 17th, 2005, 06:11 PM
#7
Re: ListView
 Originally Posted by baja_yu
The only downside I think is that if you doubleclick on empty space it will tirgger the code.
That's just the point. But you might have many items in the listview. The first is selected, you've scrolled down (the selected item is not visible) and you double click on the side of one item which counts as a double click on an item that is not even visible. But of course if that doesn't matter go with it, I just answered your question "What's wrong with this"
-
Mar 17th, 2005, 06:15 PM
#8
Thread Starter
Hyperactive Member
Re: ListView
Yeah... that was what was happening Joacim.... thanks for the help!
Ash Nazg durbatuluk, Ash Nazg gimbatul, Ash Nazg tharkathuluk, Agh barzum-ishi krimpatul.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|