将动态创建的TextBox对象传递给另一个方法?

时间:2017-03-05 16:44:59

标签: c#

如何将TextBox对象传递给textBox1_TextChanged方法?

    public void textBox1_TextChanged(object sender, EventArgs e)
    {

       //I would like to do something like string value = tb.Text;

    }

//method for creating TextBox on button click, than firing event to save value
//from user input on TextChanged

    public void button1_Click(object sender, EventArgs e)
    {

        TextBox tb = new TextBox();

        this.Controls.Add(tb);
        tb.BringToFront();
        tb.Click += new System.EventHandler(textBox1_TextChanged);
    }

我知道这是基本的,但我是新手。 谢谢你的帮助。

0 个答案:

没有答案