I have got four buttons in my form among four three buttons (btn2 btn3 btn4) have same color.
when btn1 is clicked it will check if btn2 btn3 and btn4 are of same color without explicitly stating what color to compare. but my condition does not seem to be right should i state this
the code I'm using is:
private void btn1_Click(object sender, EventArgs e)
{
if (btn2.BackColor.Equals((btn3.BackColor) && (btn4.BackColor)))
{
MessageBox.Show("ALL BUTTONS ARE OF SAME COLOR");
}
}
Use this code to compare colors:
if (btn2.BackColor == btn3.BackColor && btn3.BackColor == btn4.BackColor)
{
MessageBox.Show("ALL BUTTONS ARE THE SAME COLOR");
}
else
{
MessageBox.Show("ALL BUTTONS ARE NOT THE SAME COLOR");
}
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