0

How can I detect if I right click on my NotifyIcon?

I tried this but "Button" gets redmarked.

 private void noi_Click(object sender, EventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                MessageBox.Show("test");
            }
        }
spunit
  • 523
  • 2
  • 6
  • 23

2 Answers2

0

NotifyIcon has a ContextMenu property. Use that.

Joey
  • 344,408
  • 85
  • 689
  • 683
0

A ContextMenu is not what I want. But I found a way:

private void noi_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                LEFTORRIGHT = "left";
            }
            if (e.Button == MouseButtons.Right)
            {
                LEFTORRIGHT = "right";
            }
        }
    private void noi_Click(object sender, EventArgs e)
        {
            if (LEFTORRIGHT == left)
            {

            }
            if (LEFTORRIGHT == right)
            {

            }
        }
spunit
  • 523
  • 2
  • 6
  • 23