string[ ] a=new string[5]{"1","2","3","4","5"};
int count = 0;
foreach (var item in this.Controls)
{
if (item is TextBox)
{
count++;
TextBox te = item as TextBox;
te.Text = a[Convert.ToInt32( te.Tag)-1];
}
if (count == 5)
break;
}
100同理。自己修改下。
如果textbox是动态添加的。就在添加的时候写上textbox.Tag=对应的textbox后的值。
比如textbox22.就写上textbox.Tag=22;
如果是手动添加。就找到其属性tag写上对应的值就可以了。
温馨提示:答案为网友推荐,仅供参考