如何覆盖Button单击EventArgs或使用其他方法来实现它? [英] How to override Button Click EventArgs or use another ways to achieve it?

查看:69
本文介绍了如何覆盖Button单击EventArgs或使用其他方法来实现它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何覆盖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!

推荐答案

您必须在某个地方设置bool参数,对吗?这会解决您的目的吗?

You must be setting the bool parameter somewhere, right? Won''t this be solving your purpose?

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或使用其他方法来实现它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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