我的是点击按钮实现的
private void button1_Click(object sender, EventArgs e)
{
this.BackColor = Color.Red; //当前颜色变为红色
}
private void button2_Click(object sender, EventArgs e)
{
this.BackColor = Color.Blue; //当前颜色变为蓝色
}
private void button3_Click(object sender, EventArgs e)
{
this.BackColor = Color.Green; //当前颜色变为绿色
}
private void button4_Click(object sender, EventArgs e)
{
this.BackColor = Color.Empty; //清楚颜色格式
}
声明两个字段
private List
private int index = 0;
按钮点击事件代码
index = (index+1)%3
button.BackColor = colors[index];
1.设置颜色枚举类
2.先设置颜色,鼠标点击事件中,再改变颜色,多次循环实现
在Mouse_click事件中写 this.BackColor=你要的颜色值