winform字体闪烁

来源:互联网 发布:json转化为字符串 编辑:程序博客网 时间:2024/05/16 12:58

让字体和颜色进行变化


方法1:
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (this.timer1.Interval%2==0)
            {
                this.Rtb_ItemCheck.ForeColor = Color.BlueViolet;
                this.Rtb_ItemCheck.Font = new Font("微软雅黑", 10.5F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(134)));
            }
            else
            {
                this.Rtb_ItemCheck.ForeColor = Color.Red;
                this.Rtb_ItemCheck.Font=new Font("微软雅黑", 9F,FontStyle.Regular, GraphicsUnit.Point, ((byte)(134)));
            }
            timer1.Interval++;
        }

方法2:需要初始化控件背景


private void timer1_Tick(object sender, EventArgs e)
        {
            if (this.label1.BackColor==Color.Red)
            {
                this.label1.BackColor = Color.Aqua;
                this.label1.Font = new Font("微软雅黑",15F,FontStyle.Bold,GraphicsUnit.Point,134);
            }
            else
            {
                this.label1.BackColor = Color.Red;
                this.label1.Font = new Font("圆幼", 12F, FontStyle.Bold, GraphicsUnit.Point, 134);
            }
        }

0 0
原创粉丝点击