C#更改按钮的背景颜色 [英] C# Change A Button's Background Color

查看:4262
本文介绍了C#更改按钮的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用C#和Visual Studio 2010,我该怎么改变一个按钮的背景颜色,一旦另一个按钮是pressed?难道我不包括系统?错了?

Using C# and Visual Studio 2010, how can I change the background color of a button once another button is pressed? Am I not including a System.? wrong?

我目前所面对的是:

ButtonToday.Background = Color.Red;

ButtonToday.Background = Color.Red;

和它不工作。

推荐答案

WinForm的:

private void button1_Click(object sender, EventArgs e)
{
   button2.BackColor = Color.Red;
}

WPF:

private void button1_Click(object sender, RoutedEventArgs e)
{
   button2.Background = Brushes.Blue;
}

这篇关于C#更改按钮的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆