此代码立即将文本框更改为红色。我想要它,单击按钮然后是红色,然后是绿色。
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;
}
}