0

I am working on a math problem generator and for the current context I'm trying to check if both of the boxes are unchecked, a user can choose 1 or both of the check boxes but I want to display an error stating that at least 1 must be chosen for the type of math to be generated. I know I can check if they are both checked with

if (checkBoxAddSub.Checked && checkBoxMultDiv.Checked)

but I want to see if both of are unchecked, which as far as I know can only be done with checkstate but I'm getting an error with

if (checkBoxAddSub.CheckState == unchecked && checkBoxMultDiv.CheckState == unchecked)

Just looking for clarification.

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by loserspearl
1

The checked method returns a boolean, true if checked false if otherwise. So you can use

if (!checkBoxAddSub.Checked && !checkBoxMultDiv.Checked)

0

ty, thought i could only do !=

This question has already been answered. 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.