小编Kan*_*iet的帖子

此代码会立即将文本框更改为红色.我想要它,点击按钮然后红色,然后再绿色

此代码会立即将文本框更改为红色.我想要它,点击按钮然后红色,然后再绿色.

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;
    }
}
Run Code Online (Sandbox Code Playgroud)

c# if-statement button

3
推荐指数
2
解决办法
2765
查看次数

标签 统计

button ×1

c# ×1

if-statement ×1