默认的panel控件在重画时会出现闪烁的问题
解决问题的方法是在继承原有panel属性的基础上赋予它双缓冲的功能
在Form类中添加如下代码
1 /// <summary>
2 /// 双缓冲panel
3 /// </summary>
4 public class DoubleBufferPanel : Panel
5 {
6 public DoubleBufferPanel()
7 {
8 this.SetStyle(ControlStyles.AllPaintingInWmPaint | //不擦除背景 ,减少闪烁
9 ControlStyles.OptimizedDoubleBuffer | //双缓冲
10 ControlStyles.UserPaint, //使用自定义的重绘事件,减少闪烁
11 true);
12 }
13 }
然后找到panel控件定义和初始化的地方
将
private System.Windows.Forms.Panel panel1;
this.panel1 = new System.Windows.Forms.Panel();
private DoubleBufferPanel panel1;
改成
this.panel1 = new DoubleBufferPanel();
原文地址:http://www.cnblogs.com/shenbimanong/p/3971342.html
原创文章,转载请注明:转自于122&&113
本文链接地址:C# GDI+ Panel 双缓冲技术