先给个代码     
            textBox1.Text = "";
            checkBox6.Checked = false;
            checkBox5.Checked = false;
            checkBox4.Checked = false;
            checkBox3.Checked = false;
            checkBox2.Checked = false;
            checkBox1.Checked = false;
            radioButton1.Checked = false;
            radioButton2.Checked = false;
            radioButton3.Checked = false;
            radioButton4.Checked = false;
            checkBox1.Enabled=true;
            checkBox2.Enabled=true;
            checkBox2.Enabled=true;
            checkBox3.Enabled = true;
            checkBox4.Enabled = true;
            checkBox5.Enabled = true;
            checkBox6.Enabled = true;在C#中,
大家懂得,这是我在给一个“取消”  button  来做重置的代码
但是也太麻烦了吧?有没有简单点的重置方法?

解决方案 »

  1.   

    方法有两个
      
     1 放到一个组里面,groupBox或者 Panel    设置他们的属性,对应就改变了。 2  EnabledChanged或者Checkedhanged 事件设为一个。
      

  2.   

    把Button的名字起有规律点 或装进数组 循环遍历
      

  3.   

    方法一:把checkButton放在一个groupBox里,让checkButton互斥;把RadioButton放在另一个groupBox里!
    方法二:封装一个方法,进行判断:
            只要是checkButton就把他的Enable属性置为true;同时把他的check属性置为false;
            只要是RadioButton就把他的Checked 属性置为 false;
      

  4.   

     foreach (Control item in this.Controls)
                {
                    if (item is CheckBox)
                    {
                        CheckBox ck = item as CheckBox;
                        ck.Checked = false;
                    }
                    if (item is RadioButton)
                    {
                        RadioButton rd = item as RadioButton;
                        rd.Checked = false;
                    }                if (item is TextBox)
                    {
                        TextBox tb = item as TextBox;
                        tb.Text = "";
                    }
                }这是在winform窗体里哦 如果有groupBox或者 Panel,还得递归哦asp.net里面也不一样的
      

  5.   

    各位大哥正是好本事。无论放在 Panel或是用用Control来遍历,都是好方法。不过用panel会添加在客户端的负担,如果前台的RadioButton都需要处理的话,用control来可能更好一点。