新的EventHandler [英] new EventHandler
本文介绍了新的EventHandler的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
Hi everyone
/* what the mining of this line button1.Click += new EventHandler(button1_Click);*/
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_MouseMove(object sender, MouseEventArgs e)
{
Button button1 = new Button();
button1.Click += new EventHandler(button1_Click); /* what the mining of this line */
// MessageBox.Show("move");
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("click");
}
推荐答案
好吧,这一行:
button1.Click += new EventHandler(button1_Click);
表示您要将名为button1_Click
的单击事件处理程序附加到放置在表单上的 button1 上.
因此,此后每当您单击button1时,都会引发此事件,并且将执行在button1_Click
方法中编写的任何代码.
Well, this line:
button1.Click += new EventHandler(button1_Click);
means that you are attaching a click event handler namedbutton1_Click
to the button1 placed on your form.
Thus, after this whenever you click button1, then this event would be raised and whatever code is written inbutton1_Click
method will be executed.
这篇关于新的EventHandler的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文