This code changes the textbox instantly to red. I want it like, click button then red, again then green
Posted
by
user1803685
on Stack Overflow
See other posts from Stack Overflow
or by user1803685
Published on 2012-11-06T16:09:39Z
Indexed on
2012/11/06
17:00 UTC
Read the original article
Hit count: 311
This code changes the textbox instantly to red. I want it like, click button then red, again then green.
private void button1_Click(object sender, EventArgs e)
{
textBox1.BackColor = System.Drawing.Color.Black;
if (textBox1.BackColor.Equals(System.Drawing.Color.Black))
{
textBox1.BackColor = System.Drawing.Color.Red;
}
if (textBox1.BackColor.Equals(System.Drawing.Color.Red))
{
textBox1.BackColor = System.Drawing.Color.Green;
}
if (textBox1.BackColor.Equals(System.Drawing.Color.Green))
{
textBox1.BackColor = System.Drawing.Color.Blue;
}
if (textBox1.BackColor.Equals(System.Drawing.Color.Blue))
{
textBox1.BackColor = System.Drawing.Color.Red;
}
}
© Stack Overflow or respective owner