首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

施用循环向多个testbox输入数据

2011-12-17 
使用循环向多个testbox输入数据有多个textbox,如果一个一个的输入太麻烦,想用for循环,但是系统不认textbox

使用循环向多个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中 已经调试通过

热点排行