Determine right/left mouse click on Click/DoubleClick event

  • Thread starter Thread starter cmelnick
  • Start date Start date
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
 
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
 
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?
 
Back
Top