简体   繁体   English

在加载时如何延迟显示WinForm以防止其控件闪烁?

[英]How can I delay showing a WinForm to prevent its controls from flickering when loading up?

Okay so my form has a lot of Nested "Panels" with background images and a lot of buttons on it. 好的,我的表单上有很多带有背景图片的嵌套“面板”,并且上面有很多按钮。 Every time the form is shown (Not Minimize/Restore but Hide/Show) the controls flicker as they are rendered onto the screen. 每次显示表单时(不是最小化/还原而是隐藏/显示),控件在呈现到屏幕上时都会闪烁。

I could use opacity with a minimum delay to render the controls before setting opacity to 100%. 我可以在设置不透明度为100%之前使用不透明度最小的延迟来渲染控件。 But I was wondering if there was a better way to do this. 但是我想知道是否有更好的方法可以做到这一点。 .Net being event driven I was hoping there would be a way to detect when all controls were shown properly on the Winform before "Show"ing the winform itself. .Net是事件驱动的,我希望有一种方法可以在“显示” winform本身之前检测何时所有控件正确显示在Winform上。

I've tried this::DoubleBuffered=true; 我已经试过this::DoubleBuffered=true; on the Winform but it didn't work out as expected. 在Winform上,但是没有按预期进行。

Someone may explain why, but putting this below method in a form helped me to avoid flickering problems in my panels which has multiple button and image controls. 有人可能会解释为什么,但是将下面的这种方法放在表格中可以帮助我避免面板上有多个按钮和图像控件的闪烁问题。 Need to mention that my controls were created (dynamically) at code behind. 需要提及的是,我的控件是在后面的代码中(动态)创建的。

    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams cp = base.CreateParams;
            cp.ExStyle |= 0x02000000;  // Turn on WS_EX_COMPOSITED
            return cp;
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将布尔值绑定到控件的可见性时,如何防止闪烁 - How can I prevent flickering when binding a boolean to the visibility of a control 使用用户绘制的控件显示表单时如何避免屏幕闪烁? - How to avoid screen flickering when showing form with user drawn controls? 加载窗口的组件/类时如何避免窗口闪烁。 - how to avoid the flickering of a windows for when loading its components/classes. 如何在使用tabControl.TabPages [0] .Controls.Add()时停止表单闪烁? - how can i stop form flickering when using tabControl.TabPages[0].Controls.Add()? 水平滚动时如何防止DataGridView闪烁? - How to prevent DataGridView from flickering when scrolling horizontally? 如何减少对True Transparency WinForm更新的闪烁?或者有更好的方法吗? - How can i reduce flickering on updates to my True Transparency WinForm? or is there a better way to do this? 我可以使用WinForm控件数组而不用VS使其内裤扭曲吗? - Can I use arrays of WinForm controls without VS getting its panties in a twist? 从一个winform切换到另一个winform时,面板闪烁 - Panel is flickering when switching from one winform to another 如何防止面板更改其子控件的大小 - How to prevent panel from changing its children controls' sizes 如何控制控件的加载顺序? - How can I control the loading sequence of controls?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM