求在VS2010中,使Button中的字体在点击它时字体变色,鼠标离开时颜色又变回来的代码?
解决方案
16
wpf可以直接在xaml中设置,winfrom在button的鼠标移动事件添加修改button字体和颜色代码,在鼠标离开时添加恢复代码
12
WinForm中:
private void button5_Click(object sender, EventArgs e)
{
button5.BackColor = Color.Red;
button5.ForeColor = Color.Blue;
}
private void button5_MouseLeave(object sender, EventArgs e)
{
button5.ForeColor = SystemColors.ControlText;
button5.BackColor = SystemColors.Control;
button5.UseVisualStyleBackColor = true;
}