因为,绘图闪烁太厉害了.可以继承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.....? 这样的话会覆盖你绘制的图案的。