Herons_Robt
2017-09-16 07:10C# button 点击改变背景颜色 怎么给初始化button使颜色处于点击前的状态
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.button1.Enter += button_Enter;
this.button1.Leave += button_Leave;
this.button2.Enter += button_Enter;
this.button2.Leave += button_Leave;
//继续写其他的
}
void button_Leave(object sender, EventArgs e)
{
(sender as Button).BackColor = SystemColors.Control;
}
void button_Enter(object sender, EventArgs e)
{
(sender as Button).BackColor = Color.Red;
}
}
- 点赞
- 回答
- 收藏
- 复制链接分享
3条回答
为你推荐
- 以下C#程序运行时,二维数组用户初始化之后输入start,清屏后输出46乘47个“O ",而不是开始正常生命游戏运行,如何解决?
- c#
- visual studio
- 2个回答
- 在C#中如何使窗体间传combobox当前选中的值,而不是初始化后的combobox的第一个数据
- sqlite
- c#
- visual studio
- 4个回答
- 求助:c#窗体初始化异常
- c#
- visual studio
- 1个回答
- 由于套接字没有连接并且没有提供地址,发送或接收数据的请求没有被接受?
- c#
- 2个回答
- android ksoap2调用webservice android端代码应该怎么写 跪求!
- 1个回答
换一换