Visual C# Form right click button

后端 未结 3 1525
北海茫月
北海茫月 2020-12-20 12:46

I am trying to make a minesweeper type game in visual c# and I want to have different things happen when I right click and left click a button, how do I do this?

I h

3条回答
  •  有刺的猬
    2020-12-20 13:11

    Just try with button1_MouseDown event instead of button1_MouseClick Event.It will solve your problem.

     private void button1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
              //do something
            }
            if (e.Button == MouseButtons.Right)
            {
              //do something
            }
        }
    

提交回复
热议问题