日期:2014-05-19  浏览次数:20817 次

请教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;
}