Identify Mouse Button Clicks on controls

J

James

hi all

when we click on Control, Both Left as well as Right Mouse Button Click
gives the same functionality. Is there any solution to filter that
only Left mouse clicks allowed. Actually I have more than one clikable
controls on my UserControl giving the same functionality.
Any better ideas than to capture individual Mouse events of every
contained control.

Thanx in advance
James
 
S

SMJT

You could just check which mouse button was pressed

protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);

if (e.Button == MouseButtons.Left)
MessageBox.Show("Pushed left button");

if (e.Button == MouseButtons.Right )
MessageBox.Show("Pushed right button");
}
It's a bit basic but should do the trick.
 
J

James

hello dear,
I had made a usercontrol containing No. of clickable child
controls.
thanks for your Help.
But Overriding OnMouseDown event in my User control would catch
only Mouse clicks on thus parent control not on child controls.
I also want to check if any Child control is clicked and which User has
preesed which Button ( Left or right). But doing this way , I have to
handle Mouse event on each child controls also which is in efficient.
any Better Ideas you have, can solve my problem.

Thanks
James
 

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