110,534
社区成员
发帖
与我相关
我的任务
分享
UserControl.ControlCollection cc = this.flowLayoutPanel1.Controls;
foreach (UserControl con in cc)
{
if (con is UserControl)
{
con.Controls[0].Text = "0";
}
// else { MessageBox.Show("没有找到文本框!"); }
}
public partial class Form1 : HSEI.Windows.Forms.RobbinForm
{
private List<TextBox> tbList = new List<TextBox>();
public Form1()
{
InitializeComponent();
Init();
}
private void Init()
{
for(int i=0;i<10;i++)
{
TextBox tb = new TextBox();
tb.Text = "";
tbList.Add(tb);
//TODO Layot Add Control
}
}
private void Reset()
{
foreach(var tb in tbList)
{
tb.Text = "0";
}
}
}
你的程序中把TextBox换成自定义控件就行了