Home All Groups Group Topic Archive Search About

Identify Mouse Button Clicks on controls

Author
11 Jul 2006 8:58 AM
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

Author
11 Jul 2006 11:05 AM
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.
SMJT
James wrote:
Show quote
> 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
Author
11 Jul 2006 12:15 PM
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



SMJT wrote:
Show quote
> 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.
> SMJT
> James wrote:
> > 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

AddThis Social Bookmark Button