C#遍历窗体控件代码,遍历窗体所有按钮控件代码
foreach(Control c in this.Controls)
{
listBox1.Items.Add(c.Name);
Control c1 = c as Button;
if(c1!=null)
{
c1.Text="This is A Button";
}
}
{
listBox1.Items.Add(c.Name);
Control c1 = c as Button;
if(c1!=null)
{
c1.Text="This is A Button";
}
}
知识点:类型转换
浙公网安备 33010602011771号