我根据用户选择(1-5)创建多个文本框。如何在文本更改时访问编程文本框的值。如何在文本更改时从编程文本框中获取文本?
class starts{
int i=0;
.....
TextBox txtb4 = new TextBox();
txtb4.Name = "textname" + Convert.ToString(i);
ArrayText.Add(txtb4);
System.Drawing.Point p5 = new System.Drawing.Point(120, 15);
txtb4.Location = p5;
txtb4.Size = new System.Drawing.Size(80, 30);
txtb4.Text = stringMy;
grBox1.Controls.Add(txtb4);
i++;
}
我可以使用下面的代码访问初始文本框文本,但在更改值后我无法访问它。
label15.Text = grBox1.Controls["textname0"].Text;
你的意思是你需要处理TextChanged事件或者控制的没有发现?什么是错误?什么不行? – MarioDS
[类似的问题](http://stackoverflow.com/questions/4953853/onkeyup-event-asp-net) upvotes的答案为您提供了所需的信息,但您应该在发布之前进行搜索。它已被多次回答。 –
对于很多盒子你可以做一个foreach控制grBox1 –