渲染WinForms控件更顺畅控件、更顺畅、WinForms

2023-09-03 03:07:54 作者:患得患失像神经!

我的WinForms应用程序的渲染非常不连贯。是否有可用于任一绘制形式关屏,或有它被隐藏之前的布局已经被处理的技术?任何事情来帮助加快我的形式的视觉负担。

My winforms application is rendering very choppy. Is there a technique that can be used to either draw a form off screen, or to have it be hidden until the layout has been processed? Anything to help speed up the visual load of my forms.

感谢您的帮助。

编辑:

形式各有一对夫妇的网格,并在20 - 30其他控件(文本框/复选框)。所有的控制都是第三方的,我没有做任何的风俗画自己。

Forms have a couple grids each, and around 20 - 30 additional controls (textboxes / checkboxes). All controls are third party and I don't do any custom painting myself.

推荐答案

正在越来越危险地接近你的表格上有太多的控制。你会看到每个控件的交替其绘画本身。双缓冲无法修复这个问题,所有的控制窗口,整个表格必须是双缓冲。这是可能的,因为XP,它支持WS_EX_COMPOSITED窗口样式标志。它不会加快画画,但屏幕不会被更新,直到所有的渲染完毕。

You are getting perilously close to having too many controls on your form. You'll see each control taking its turn painting itself. Double buffering cannot fix this, the entire form with all control windows would have to be double-buffered. That's possible since XP, it supports the WS_EX_COMPOSITED window style flag. It won't speed up painting but the screen won't be updated until all rendering is completed.

粘贴此code到表单来启用它:

Paste this code into your form to enable it:

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