0

Hello,

I have a few checkboxes thatwhen you check them, they set a varible to bool.

For example, if someone selected that they want to see a square it would then change the bool "square = true" however, when someone unchecks the checkbox, I want the boolen to go back to false again, any ideas?

private void squareCheck_CheckedChanged(object sender, EventArgs e)
{
     square = true;
}

Many thanks =)

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by Momerath
1

Try this:

private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox chBox = sender as CheckBox;
            square = chBox.Checked;
        }
0

Hey thanks for the reply however it displays an error saying this method already exists. It's rather important too!

Any other suggestions?

Thanks :)

0

I'm confused :(

private void squareCheck_CheckedChanged(object sender, EventArgs e)
{
     CheckBox chBox = sender as CheckBox;            
     square = chBox.Checked;
}

How would I be able to check that it is unchecked?

0

chBox.Checked is true if it is checked, false if it is not checked. Did you bother to read any documentation on the checkbox?

You'll probably find that 99% of the questions you have can be answered by reading the documentation.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.