马上加入IBC程序猿 各种源码随意下,各种教程随便看! 注册 每日签到 加入编程讨论群

C#教程 ASP.NET教程 C#视频教程程序源码享受不尽 C#技术求助 ASP.NET技术求助

【源码下载】 社群合作 申请版主 程序开发 【远程协助】 每天乐一乐 每日签到 【承接外包项目】 面试-葵花宝典下载

官方一群:

官方二群:

大神们,问下我的OnPaint事件为什么没有用,重绘没出来

[复制链接]
查看3162 | 回复1 | 2016-5-23 09:58:34 | 显示全部楼层 |阅读模式
代码如下,重绘但是没有用

protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            SizeF DSize = g.MeasureString("√", new Font(new FontFamily("宋体"), 18));
            this.Height = (int)DSize.Height;
            Rectangle Outrect = new Rectangle(0, this.Height / 2 - 6, 12, 12);
            Rectangle Inrect = new Rectangle(1, this.Height / 2 - 6 + 1, 10, 10);
            GraphicsPath path = new GraphicsPath();
            path.AddRectangle(Outrect);
            g.DrawPath(new Pen(this.Enabled ? CheckColor : Color.Silver), path);
            g.FillPath(new SolidBrush(CheckBackColor), path);
            if (Checked)
            {
                g.DrawString("√", new Font(new FontFamily("宋体"), 18), new SolidBrush(this.Enabled ? CheckColor : Color.Silver), new PointF(6 - DSize.Width / 2, this.Height / 2 - Height / 2 - 1));
            }
        }
ibcadmin | 2016-5-23 21:09:47 | 显示全部楼层
我运行后直接报进程错
C#论坛 www.ibcibc.com IBC编程社区
C#
C#论坛
IBC编程社区
*滑块验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则