日期:2014-05-17  浏览次数:20894 次

winform控件请教
本帖最后由 william0992 于 2013-12-06 11:50:52 编辑
我这有一组控件,1个checkbox控件叫name,2个textbox控件分别叫name1,name2
怎么才能够通过下面的代码在选中name的时候也能操作name1和name2

我窗口面板放了上述这样好多相似的多组控件。我不想一组一组写代码

 private void Com(Control.ControlCollection c)
        {
            richTextBox1.Clear();
            if (c.Count > 0)
            {
                foreach (Control c1 in c)
                {
                    if (c1.GetType().ToString().Equals("System.Windows.Forms.CheckBox"))
                    {
                        if(((CheckBox)c1).Checked== true)
                         {
                         //  richTextBox1.AppendText();
                         //
                         }
                    }

                    if (c1 != null)
                    {
                        Com(c1.Controls);
                    }
                    else
                    {
                        return;
                   }
                }
            }
            else
            {
                return;
           &nb