且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

按钮和表单或用户控件的事件处理程序

更新时间:2023-12-06 07:59:28

是的-只需在设计器中将事件处理程序设置为相同的方法即可.
假设您的方法存在:
1)突出显示您的按钮.
2)在属性"窗格中查看事件"(通过闪电"按钮)
3)通过单击一次来选择适当的事件(例如单击").
4)下拉菜单将出现在属性的右侧-单击以将其打开.
5)从列表中选择您的方法名称.
6)为您重复其他按钮.

现在将调用相同的方法-您可以通过"sender"参数找出哪个方法调用了它.
Yes - just set the event handler to the same method in the designer.
Assuming your method exists:
1) Highlight your button.
2) Look at the Events in the Properties pane (via the "lightning bolt" button)
3) Select the appropriate event ("Click" for example) by clicking it once.
4) A drop down will appear at the right side of the property - click it to open.
5) Select your method name from the list.
6) Repeat for you other buttons.

The same method will now be called - you can find out which called it via the "sender" parameter.