Visual C# CheckBox Usage

Example of Using CheckBox

In Visual C# applications, we can easily detect whether the checkbox object is checked or not. For this, it will be sufficient to use an if structure like the following.

if (checkBox1.Checked == true)
{
    ...
}
else
{
    ...
}

Since the Checked property will return a bool type result (either true or false), we can also use the expression as follows.

if (checkBox1.Checked)
{
    ...
}
else
{
    ...
}

Example: Suppose we have two checkboxes named CheckBox1 and CheckBox2. If both checkboxes are checked, we can enable the button as follows.

if (checkBox1.Checked && checkBox2.Checked)
{
    // done if both boxes are checked
    button1.Enabled = True;
}
else
{
    // done if one or both of the boxes are unchecked
    button1.Enabled = False;
}

 

visual c# checkbox usage example, checkbox tutorials, how to use checkbox, checking if checkbox is checked, checkbox checked feature

EXERCISES

There are no examples related to this subject.



COMMENTS




Read 871 times.

Online Users: 3874



using-checkbox-tutorials