展开全部
先拖拽一个按钮到窗体,双击按钮,进入点击事件,在点击事件中设置窗体的颜色
private void button2_Click(object sender, EventArgs e)
{
this.BackColor = Color.AliceBlue;
}
若是其他窗体的颜色则先将需要更改的窗体赋值给按钮所在的窗体如:
private System.Windows.Forms.Form Otherform = null;
public Form1(System.Windows.Forms.Form otherform)
{
Otherform = otherform;
}
private void button2_Click(object sender, EventArgs e)
{
Otherform.BackColor = Color.AliceBlue;
}
private void button2_Click(object sender, EventArgs e)
{
this.BackColor = Color.AliceBlue;
}
若是其他窗体的颜色则先将需要更改的窗体赋值给按钮所在的窗体如:
private System.Windows.Forms.Form Otherform = null;
public Form1(System.Windows.Forms.Form otherform)
{
Otherform = otherform;
}
private void button2_Click(object sender, EventArgs e)
{
Otherform.BackColor = Color.AliceBlue;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询