首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

自定义了一个继承panel的类,但是却不能绘图了,该怎么处理

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

自定义了一个继承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.....? 这样的话会覆盖你绘制的图案的。

热点排行