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 " ;
}
}
知识点:类型转换
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12639172/viewspace-627717/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12639172/viewspace-627717/