C#如何获取动态添加textbox的值

就是这段代码,我想获取动态添加的textbox的值,请问怎么做,我设置了名字,但是我不知道怎么去访问。
求详解,谢谢啦 !
private void button1_Click(object sender, EventArgs e)
{
label2.Visible = true;
label2.Text = "请填写下列" + textBox1.Text + "阶行列式每个元素的值:";
int num = int.Parse(textBox1.Text);
for (int i = 1; i != num + 1; ++i)
for (int j = 1; j != num + 1; ++j)
{
TextBox text = new TextBox();
text.Location = new Point(125 + (i - 1) * 145, 155 + (j - 1) * 60);
text.Size = new Size(45, 35);
int temp = j * 10 + i;
text.Name = "A_" + temp.ToString();
this.Controls.Add(text);
Label lab = new Label();
lab.Text = "A" + j + i;
lab.Location = new Point(70 + (i - 1) * 145, 155 + (j - 1) * 62);
lab.Size = new Size(45, 20);
this.Controls.Add(lab);
}
}

Name值可作为关键字访问控件集合
((TextBox)Controls["A_1"]).Text
温馨提示:内容为网友见解,仅供参考
第1个回答  2015-10-06
用输入事件动态写入变量就好
相似回答