Click here to Skip to main content
15,889,735 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.............



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

}
}
Posted
Updated 24-Mar-11 20:48pm
v3
Comments
Prerak Patel 25-Mar-11 2:35am    
Use <pre> tags for code
situ21 25-Mar-11 2:42am    
sir,tell me the solution of my problem
R. Erasmus 25-Mar-11 3:35am    
indent you're code to make it look appealing.

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;

from inside the If
 
Share this answer
 
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
 
Share this answer
 
C#
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
}
}


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:-)
 
Share this answer
 
Comments
situ21 25-Mar-11 4:46am    
it is not working
If you're trying to show the contents of panel1 when the box is checked, the following could work...

C#
private void checkBox4_CheckedChanged(object sender, EventArgs e)
{
   panel1.Visible = checkBox4.Checked;
}


Regards,
Frank
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900