我想调用一个按钮单击事件,如函数吗? [英] ı want to call a button click event lıke a function how can ı do?

查看:67
本文介绍了我想调用一个按钮单击事件,如函数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在任何地方打电话我该怎么办?



private void button9_Click(对象发送者,EventArgs e)
{
......
......
}

ı want to call anywhere how can ı do?



private void button9_Click(object sender, EventArgs e)
{
...............
...............
}

推荐答案

您是说这样吗?
Do you mean like this?
button9_Click( null, EventArgs.Empty );



尼克



Nick


调用任何函数的方式相同.创建一个Object对象和一个EventArgs对象,并将它们传递给您的函数,例如
The same way you would call any function. Create an Object object and an EventArgs object and pass them to your function, e.g.
Object sender = new Object();
EventArgs e = new EventArgs();
button9_Click(sender, e);


作为私有函数,您只能在包含buttonclick函数的类的一个函数中调用它.内部函数使用类对象或对象指针("this"指针).
As its a private function then you will only be able to call it inside one of the functions of the class that contains the buttonclick function.you can call it from any of the internal functions using the class object or object pointer("this" pointer).


这篇关于我想调用一个按钮单击事件,如函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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