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";
    }
}

知识点:类型转换

posted on 2010-02-21 09:05  桓源  阅读(1301)  评论(0)    收藏  举报

导航