foreach (TabPage analog in tabControl2.TabPages)
{
foreach (Control control in analog.Controls)
{
if (control is Label)
{
for (int i = 0; i < 40; i++)
{
this.analog.Controls["label" + i.ToString()].Text = "D" + (6000 + i).ToString();
}
for (int i = 0; i < 60; i++)
{
this.analog.Controls["label" + (i + 40).ToString()].Text = "D" + (6000 + i).ToString();
}
}
}
}
原先没有groupbox的时候,label可以遍历,现在把label加入groupbox中,无法遍历,我试过改成this.analog.groupBox3.Controls["label" + i.ToString()].Text = "D" + (6000 + i).ToString();没有用,提示:CS1061 “TabPage”未包含“groupBox3”的定义,并且找不到可接受第一个“TabPage”类型参数的可访问扩展方法“groupBox3”(是否缺少 using 指令或程序集引用?),这该怎么改?