遍历winform 窗体控件

 //遍历窗体控件并给控件赋值
        private void Control_Load(object sender, EventArgs e)
        {
            foreach (Control Ctr in this.Controls)
            {
                if (Ctr is System.Windows.Forms.CheckBox)
                {
                    checkBox1.Checked = true;
                }
                else if (Ctr is TextBox)
                {
                    this.textBox1.Text = "赋值数据";
                }
            }
        }

posted @ 2016-01-02 02:33  DuNiandy  阅读(218)  评论(0编辑  收藏  举报