C#点击字体变色

.Net技术 码拜 8年前 (2016-03-06) 1445次浏览
求在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;
        }

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明C#点击字体变色
喜欢 (0)
[1034331897@qq.com]
分享 (0)