首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

请问Button的OnMouseEnter和OnMouseLeave

2012-03-02 
请教Button的OnMouseEnter和OnMouseLeave有个BUTTON,当鼠标放在上面的时候BGCOLOR是红色,LEAVE的时候是绿

请教Button的OnMouseEnter和OnMouseLeave
有个BUTTON,当鼠标放在上面的时候BGCOLOR是红色,LEAVE的时候是绿色
除了重写BUTTON外     还有什么方法能直接实现的??最好有代码

[解决办法]
比如:
this.button2.MouseLeave += new System.EventHandler(this.button2_MouseLeave);
this.button2.MouseEnter += new System.EventHandler(this.button2_MouseEnter);
private void button2_MouseEnter(object sender, EventArgs e)
{
this.button2.BackColor = Color.Red;
}

private void button2_MouseLeave(object sender, EventArgs e)
{
this.button2.BackColor = Color.Green;
}

[解决办法]
private void Button1_MouseEnter(object sender, EventArgs e)
{
this.Button1.BackColor = Color.Red;
}

private void Button1_MouseLeave(object sender, EventArgs e)
{
this.Button1.BackColor = Color.Green;
}

热点排行