Hey I was wondering what the event is when the right mouse button is clicked.
Is this event included in mouseclick? If so do i have to make an if statement asking which mouse button has been pressed??
Printable View
Hey I was wondering what the event is when the right mouse button is clicked.
Is this event included in mouseclick? If so do i have to make an if statement asking which mouse button has been pressed??
Use the MouseClick event and check to see which mouse button was clicked by using e.Button, something like
VB Code:
If e.Button = Windows.Forms.MouseButtons.Right Then End If
Could you use that in an example it seems to create errors with my handle and e.button appears undefined.
It's the "MouseClick" event of the control, not the "Click" event...
VB Code:
Private Sub Form1_MouseClick(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles Me.MouseClick If e.Button = Windows.Forms.MouseButtons.Right Then MsgBox("Right click detected") End If End Sub
The MouseClick event is new in .NET 2.0. If you're using .NET 1.x (please specify in future) you have to handle the MouseDown event instead.