C# Checking if button was clicked

前端 未结 4 1918
情书的邮戳
情书的邮戳 2020-12-30 12:03

I am making a program that should just continue if 2 conditions are given.

The first one, 2 TextBoxs have the same word in and a Button wa

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-30 12:32

    button1, button2 and button3 have same even handler

    private void button1_Click(Object sender, EventArgs e)
        {
            Button btnSender = (Button)sender;
            if (btnSender == button1 || btnSender == button2)
            {
                //some code here
            }
            else if (btnSender == button3)
                //some code here
        }
    

提交回复
热议问题