自定义控件闪烁问题

今天看UI 设计 无意中  想起 之前   自定义控件闪烁的情况 于是上网搜索

http://www.docin.com/p-269578584.html

C#双缓存解决自定义控件闪屏问题 C# WinForm编程中我们经常会遇见某个自定义控件闪烁得很 厉害的情况,即便将窗体DoubleBuffered属性设置为True也无济于事。 终于万能的百度知道里问道了方法: 

base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); 

base.UpdateStyles();

 于是窗体初始化时加入上 述语句、F5、移动自定义控件, 闪依旧。 看来,加的地方不对。进入 自定义控件初始化阶段增加语 句、F5、移动自定义控件,^_^成功啦。 但是,一般地我习惯自定义 很多控件,所以就来一个一次封 装重复使用: 

namespace haha.Controls {

 public class DoubleBufferdPanel : System.Windows.Forms.Panel { public DoubleBufferdPanel() : base() { base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); 

base.UpdateStyles(); } }

 public class DoubleBufferdPictureBox : System.Windows.Forms.PictureBox 

public DoubleBufferdPictureBox() : base() 

{

 base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);

 base.UpdateStyles();

 }

 } 

public class DoubleBufferdControl: System.Windows.Forms.UserControl 

{

 public DoubleBufferdControl() : base()

 { base.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); 

base.UpdateStyles();

 }

 } 

}

然后再搜索 下面这个  说的比较详细

http://wenku.baidu.com/view/f811d6a2f524ccbff121840b.html

原文地址:https://www.cnblogs.com/jilodream/p/4222738.html