0

I want to check if the user did right click on a button which is in a toolStrip, but there's no MouseClick event for each control.

example of right clicking:

    private void tabControl1_MouseClick(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Right)
        {
            Point pt = tabControl1.PointToScreen(e.Location);
            tabContxt.Show(pt);
        }
    }

i want to do the same for the button in the toolStrip, if you can help me :). Thanks

  • This is a duplicate of this question: http://stackoverflow.com/questions/19544505/detect-right-click-on-toolstrip-button [1]: http://stackoverflow.com/questions/19544505/detect-right-click-on-toolstrip-button – Brandon Feb 24 '14 at 18:58
  • It seems that i didn't search very well, but i did search at first :/ – Noor Ali Haj Dahood Feb 24 '14 at 19:09

2 Answers2

1

You can use Mouse_Down event.

private void toolStripButton1_MouseDown(object sender, MouseEventArgs e)
{
    if (e.Button == MouseButtons.Right)
    {
    }
}
0

Try this

private void tabControl1_MouseClick(object sender, MouseEventArgs e)
{
    var zz = ((MouseEventArgs)e).Button;

    if (zz == MouseButtons.Right)
    {
        Point pt = tabControl1.PointToScreen(e.Location);
        tabContxt.Show(pt);
    }
}
ElectricRouge
  • 1,239
  • 3
  • 22
  • 33