How to change item color when the checkbox is unchecked in C # .net?

I want to change the priority of the checked item when it is not set. I used item.checked for the marked item, but what if it is not installed? im using winforms

+3
source share
3 answers

item.checked is true if the item is checked, and false if the item is not checked.

So you can do something like:

if(item.checked)
{
    //Set color
}
else
{
    //Set color of item for unchecked
}
+2
source

I assume you are looking for something like this:

private void checkBox1_CheckedChanged(object sender, EventArgs e) {
    if (checkBox1.Checked)
        checkBox1.ForeColor = Color.Green;
    else
        checkBox1.ForeColor = Color.Red;
}

, Checked CheckBox . , checkBox1.Checked , Checked == true !checkBox1.Checked ( else) , Checked == false

+4
control.Color = checkBox.Checked ? Color.Red : Color.Blue;
+2
source

Source: https://habr.com/ru/post/1737126/


All Articles