C# equivalent to VB.NET 'Handles button1.Click, button2.Click'

后端 未结 6 1031
抹茶落季
抹茶落季 2021-01-12 08:15

In VB.NET I can do

private sub button_click(sender, e) handles Button1.Click, Button2.Click etc...
do something...
end sub
6条回答
  •  醉梦人生
    2021-01-12 08:38

    Manually, you can do this:

    button1.Click += button_Click;
    button2.Click += button_Click;
    ...
    

    In the Designer, the Click event property is actually a drop-down menu where you can choose among existing methods that have the appropriate signature.

提交回复
热议问题