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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

the DoubleClick event fires when right doubleclicked?

Status
Not open for further replies.

phunugus

Programmer
Dec 26, 2002
21
0
0
US
For my listview control, the Doubleclick event fires when a users a left doubleclicks an item. But it also fires when the user right doubleclicks an item... i dont want this to happen. How do i detect left and right doubleclicks?
 
Because the DoubleClick event of the ListView does not provide any mouse information, you will need to catch the mouse button prior to the DoubleClick event firing:

Private bRight As Boolean

Private Sub ListView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDown

bRight = Convert.ToBoolean(e.Button = MouseButtons.Right)

End Sub

Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick

If bRight Then Exit Sub

MessageBox.Show("Double click fired with left mouse button!")

End Sub
 
This is another easy way to do this just move your code from your listview_doublclick to the listview_mousedown and put it inside this control structure.

If e.Button = MouseButtons.Left And e.Clicks = 2 Then
'insert listview_doubleclicked code here
End If

Hope this helps.
-Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top