This code changes the textbox instantly to red. I want it like, click button then red, again then green
- by user1803685
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;
}
}