在下面的代码中,我如何确定哪个控件引发了 Click
事件?
void x_Click(object sender, EventArgs e)
{
//How do I identify the sender?
}
private void fill()
{
for(blah)
{
Button x = new Button();
x.Click += new EventHandler(x_Click);
this.controls.Add(x)
}
}
最佳答案
void x_Click(object sender, EventArgs e)
{
Button who = (Button) sender;
// you can now access who.Text, etc.
}
关于c# - 如何识别哪个控件生成了 Click 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1506815/