解决C#开发中控件出现闪烁问题总结
最近在一个展示系统中遇到了窗体闪烁的问题,很是头疼,刚开始用双缓冲来解决,但是效果不明显,因为窗体上控件太多,而且都是根据XML动态生成出来的,后来找啊找,试啊试,终于彻底解决闪烁问题了。
参考方法的地址:
http://hi.baidu.com/zhongji/blog/item/8042adc3c604c14fb319a8a1.html
http://www.xueit.com/html/2011-04/103-1841928586201142694342406.html
我是用了 重写窗体的背景重画事件来解决闪烁问题的:
protected override void OnPaintBackground(PaintEventArgs e)
效果出奇的好,哈哈
{
Region regionClient = new Region(this.ClientRectangle);
regionClient.Exclude(
new Rectangle(panelImgOrigin.Location, panelImgOrigin.ClientRectangle.Size)
);
e.Graphics.FillRegion(new SolidBrush(this.BackColor), regionClient);
}
浙公网安备 33010602011771号