问题描述
如何覆盖Button ClickEventArgs或使用其他方法来实现它?
在button_Click中,只有两个参数(对象发送者和EventArgs e),现在我要覆盖Button_Click添加参数,如果参数为true,则执行此click事件,否则将不执行此click.
不能通过直接添加参数来覆盖button1_Click,通过覆盖EventArgs似乎是可行的,
但是我是新手,不知道如何实现此功能,如果给我详细的代码,我将非常感谢您的协助.
在此先谢谢您!
How to override Button Click EventArgs or use another ways to achieve it?
in the button_Click,there is only two parameters(object sender and EventArgs e), now I want to override the Button_Click add
a bool parameter, if the parameter is true then execute this click event, otherwise doesn''t execute this click.
It can not be overrided the button1_Click by adding a parameter directly, It seems to be feasible by override the EventArgs,
But I am a novice, and don''t know how to achieve this function, if give me detail code,I''ll very appreciate your assitance.
Thanks in advance!
推荐答案
private void button1_Click(object sender, EventArgs e) {<br /> if (SomeBoolean) {<br /> //<br /> // Code here<br /> //<br /> }<br /><br /> }
此处SomeBoolean是类级别的变量.
Here SomeBoolean is a class level variable.
这篇关于如何覆盖Button单击EventArgs或使用其他方法来实现它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!