Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何识别生成单击事件的控件?_C#_Events_Controls - Fatal编程技术网

C# 如何识别生成单击事件的控件?

C# 如何识别生成单击事件的控件?,c#,events,controls,C#,Events,Controls,在下面的代码中,如何识别引发单击事件的控件 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 EventHan

在下面的代码中,如何识别引发
单击事件的控件

    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.
}