日期:2014-05-19  浏览次数:20742 次

使用循环向多个testbox输入数据
有多个textbox,如果一个一个的输入太麻烦,想用for循环,但是系统不认   textboxi,怎么办呢?

------解决方案--------------------
System.Collections.Generic.List <TextBox> oList = new List <TextBox> ();
public Form1()
{
InitializeComponent();
oList.Add(this.tB1);
oList.Add(this.tB2);

}

private void button2_Click(object sender, EventArgs e)
{
if(this.tbInput.Text.ToString().CompareTo( "1 ")==0)
{
oList[0].Text = this.tbInput.Text;
}
else
{
oList[1].Text = this.tbInput.Text;
}
}

在VS2005中 已经调试通过