复选框不是一键签入,也不是一键注销 [英] checkbox is not check in one click and not uncheck in one click

查看:77
本文介绍了复选框不是一键签入,也不是一键注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在复选框中使用此代码,但使用此代码后,我的复选框无法正常工作.就像一键未选中一样,选中后也不会一键取消.
请帮助我.............



hello ,I''m using this code in the checkbox but after use this,my checkbox is not work properly like. Like it is not checked in one click and after checked it is not unchecked in one click.
please help me.............



private void checkBox4_CheckedChanged(object sender, EventArgs e)
        {
            
 if (checkBox4.Checked == true)
            {
                panel1.Show();
                radioButton1.Show();
                radioButton2.Show();
                radioButton3.Show();
                radioButton9.Show();
                radioButton8.Show();

}
}

推荐答案

您是说它也具有复选框内显示"block"的状态.如果是这种情况,请将ThreeState 属性更改为false.

同样,如果您已经将Checked 属性设置为true ,也不必将其设置为true ,则可以将其删除:
Do you mean you it also has a state where a ''block'' is shown inside the checkbox. If that''s the case change the ThreeState property to false.

Also you don''t have to set the Checked property to true if it already is true so you can remove:
checkBox4.Checked=true;


从If


from inside the If


内部,您需要将单选按钮放在组框中.您也不应显示/隐藏.您有他们的父面板.使用MyPanel.Visible = some_boolean;.这样,您可以显示/隐藏面板及其所有子项,并使子项始终可见.

-SA
You need to put radio buttons in a group box. You also should not Show/Hide then. You have their parent panel. Use MyPanel.Visible = some_boolean;. In this way, you show/hide panel with all its children, and keep children visible all the time.

—SA


private void checkBox4_CheckedChanged(object sender, EventArgs e)
        {

 if (checkBox4.Checked == true)
            {
                panel1.Show();
                radioButton1.Show();
                radioButton2.Show();
                radioButton3.Show();
                radioButton9.Show();
                radioButton8.Show();
                
                //checkBox4.Checked=true; remove this line
}
}



在检查条件为true之后,您再次将checkbox的状态定义为true ..似乎是问题,尝试将checked状态设置为false或无需再​​次声明checkbox的状态..
快乐的编码:-)



after checking the condition with true you are again defining the state of checkbox to true.. seems to be the problem try it out with checked state as false or no need to declare again state of checkbox..
happy coding:-)


这篇关于复选框不是一键签入,也不是一键注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆