按钮和表单或用户控件的事件处理程序 [英] event handlers for "buttons and form or user controls

查看:80
本文介绍了按钮和表单或用户控件的事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单击事件处理程序?我的项目中至少有5个按钮",每个被单击的按钮都必须显示相应的用户控件.使用.show和.hide方法看起来不像是引发click事件的正确方法.

有没有一种方法可以将一个按钮单击事件等同于所有按钮和表单

Clicked event-handlers? My project has minimum 5 "buttons" and each on being clicked must show the corresponding user control.Using the .show and .hide methods looks not like its the right way of evoking the click event.

Is there a way of equating one button clicked event to all the buttons and forms

推荐答案

是的-只需在设计器中将事件处理程序设置为相同的方法即可.
假设您的方法存在:
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.


这篇关于按钮和表单或用户控件的事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆