读书人

自定义了一个继承panel的类,但是却不能

发布时间: 2012-01-03 22:16:06 作者: rapoo

自定义了一个继承panel的类,但是却不能绘图了
因为,绘图闪烁太厉害了.可以继承panel来消除

C# code
using System;using System.Collections.Generic;using System.Text;using System.Windows.Forms;namespace 贪吃蛇{    public class PanelNew : Panel    {        public PanelNew()            : base()        {            SetStyle(ControlStyles.UserPaint, true);            SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.             SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲             this.UpdateStyles();            //SetStyle(ControlStyles.UserPaint | ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);            //this.UpdateStyles();        }    }}


[解决办法]
你的那些 SetStyle 不是已经解决闪烁的问题了吗,接下来在 Paint 事件里面画图不就行了?
[解决办法]
是在 paint 事件里画的吗?
[解决办法]
Paint 事件里是否有 base.Paint.....? 这样的话会覆盖你绘制的图案的。

读书人网 >.NET

热点推荐