Member Avatar

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.

Recommended Answers

All 2 Replies

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

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

Member Avatar

ty, thought i could only do !=

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.