Mouse Event

  • Thread starter Thread starter KAB
  • Start date Start date
K

KAB

Hi All:
In my application I need to determine whether a left click or a right click
of the mouse on a Visual Basic button produced the event. Is there any code
that can distinguish which mouse button actually produced the event?

Thanks
KAB
 
KAB said:
Hi All:
In my application I need to determine whether a left click or a right
click
of the mouse on a Visual Basic button produced the event. Is there any
code
that can distinguish which mouse button actually produced the event?

Thanks
KAB

What you want to look at is the shared function:

Control.MouseButtons

In the event check the value against the enum values to find out which
button was pressed.

Note that you can use a control from your GUI but you will get the squiggly
line indicating that you are using a Shared function.

LS
 
KAB said:
Hi All:
In my application I need to determine whether a left click or a right
click of the mouse on a Visual Basic button produced the event. Is
there any code that can distinguish which mouse button actually
produced the event?

If DirectCast(e, MouseEventArgs).Button = Windows.Forms.MouseButtons.Right
Then

End If


I didn't see this in the documentation, but hovering over "e" in debug mode,
it showed the values X, Y, and Button. Didn't know where they came from,
first, because "e." didn't show these values.


Armin
 
KAB said:
Hi All:
In my application I need to determine whether a left click or a right click
of the mouse on a Visual Basic button produced the event. Is there any code
that can distinguish which mouse button actually produced the event?

Thanks
KAB

Hi All:
Thanks for your help. I just found out that my version of Visual Basic only
allows the buttons to be left click and rejects the right click. So I have
to rethink my code now.

Thanks again.
 
Hi All:
Thanks for your help. I just found out that my version of Visual Basic only
allows the buttons to be left click and rejects the right click. So I have
to rethink my code now.

Thanks again.

It has nothing to do with the version of VB .NET. Control's Click
event fires only for left button clicks. Use the MouseDown or MouseUp
events for other button clicks.
 
Back
Top