How to create an event handler for multiple buttons?

前端 未结 3 1770
孤街浪徒
孤街浪徒 2020-12-22 03:10

In my C# project, I am creating a Hangman game that has a set of buttons which contains the alphabets from A to Z. All these buttons when clicked will execute the same metho

3条回答
  •  醉话见心
    2020-12-22 03:29

    Something like

    private void Button_Click(object sender, EventArgs e)
        {
            Button b = (Button) sender;
            //button name
        }
    

    msdn

提交回复
热议问题