Page_load上的屏幕闪烁 [英] screen flicker on Page_load

查看:90
本文介绍了Page_load上的屏幕闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用程序:基于窗口的(C#.net VS2008)

场景:我的表单具有包含图像和其他控件的TableLayout

问题:页面加载时屏幕闪烁(页面加载时没有代码)

如何避免/停止闪烁?

任何有用的解决方案吗?

Application : Windowbased (C#.net VS2008)

Scenario : My form having a TableLayout with Image and other controls

Problem : screen flicker on Page_load (There is no code on page load)

how do i avoid/stop flickering ?

Any helpful solution ?

推荐答案

由于控件重画而发生闪烁.
使用 control.DoubleBuffered 属性.将其设置为true.
DoubleBuffered允许Control使用辅助缓冲区重绘其表面以避免闪烁.

在.cs页面中编写以下功能
Flickering occurs due to control Repainting.
use control.DoubleBuffered property. set it to true.
DoubleBuffered allows Control redraws its surface using secondary buffer to avoid flickering.

write following function in .cs page
public static void enableDoubleBuff(System.Windows.Forms.Control cont)
        {
            System.Reflection.PropertyInfo DemoProp = typeof(System.Windows.Forms.Control).GetProperty("DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            DemoProp.SetValue(cont, true, null);
        }



在InitializeComponent()之后在表单构造函数中调用函数



call function in form constructor after InitializeComponent()

this.DoubleBuffered = true;
enableDoubleBuff(TableLayoutPanelName);


这篇关于Page_load上的屏幕闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆