Mouse Event

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
 
L

Lloyd Sheen

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
 
A

Armin Zingler

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
 
K

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

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.
 
J

Jack Jackson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top