i want to change the forecolor of the checked item when it is unchecked.. for checked item i have used item.checked but what to do if it is unchecked? im using winforms
I suppose 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;
}
As you might know, the Checked property of the CheckBox control is a boolean. So testing for checkBox1.Checked
results in a changes if Checked == true, and !checkBox1.Checked
(or an else block) results in changes if Checked == false
control.Color = checkBox.Checked ? Color.Red : Color.Blue;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With