Determine right/left mouse click on Click/DoubleClick event

C

cmelnick

I need to determine whether the user used the right or left mouse
button to click an element on a form. AFAIK, there is no way to
determine this from the Click (or DoubleClick) event. I currently have
my form set up to have a MouseButtons instance that gets updated by the
MouseDown event, then the Click event checks the instance to see if it
was right or left. This works fine, but seems a very roundabout and
clumsy way to do something simple.

Is there a better way to do this?

Thanks in advance,
Chris
 
G

Guest

The MouseEventArgs argument received in MouseDown can be used to see which
button was clicked. Assuming you named this argument object mea, you can do
this

if (mea.Button == MouseButtons.Right) // it's the right button
 
C

cell18189

I've been coming across this problem more than once. It's a pain, but I
haven't found a solution to it yet, except the roundabout way that you
have mentioned. Annoying, eh?
 

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