且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取文本框的文本是动态创建的

更新时间:2023-12-05 10:14:28

在Click事件处理程序中,您将有一个参数"sender"-这是导致事件的TextBox:
In the Click event handler, you will have a parameter "sender" - this is the TextBox that caused the event:
TextBox t = sender as TextBox;
if (t != null)
   {
   Console.WriteLIne(t.Text);
   }


TextBox
Click事件处理程序中使用以下代码
Use the following code in the Click event handler of the TextBox
void t_Click(object sender, EventArgs e)
{
    TextBox t1 = (TextBox)sender;
    string str = t1.Text; 
}