我正在制作一个 Windows 窗体应用程序,主要是我的屏幕分为 3 个部分,例如
===========================================================================
Top panel (it doesn't flicker)
===========================================================================
|| || 'it has a panel & panel contains a table layout,this tabble layout'
|| || 'has a picture box and a label, picture & text of label is'
|| ||'changed on the click of side bar menu' (PROB: this flickers a lot)
||side bar ||==============================================================
||(doesn't ||'this part also has a panel and panel contains different table'
||flicker) ||'layouts and on the click of a menu, related table layout is shown and'
|| ||'some of the parts of table layout are created dynamically.'
|| ||
|| || (PROB: this flickers a lot)
|| ||
我搜索了很多,到处都找到了这个解决方案,我尝试了这个
public constructor()
{
InitializeComponent();
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.DoubleBuffered = true;
DoubleBuffered = true;
SetStyle(ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw |
ControlStyles.ContainerControl |
ControlStyles.OptimizedDoubleBuffer |
ControlStyles.SupportsTransparentBackColor
, true);
}
我也试过这个
protected override CreateParams CreateParams
{
get
{
CreateParams handleParam = base.CreateParams;
handleParam.ExStyle |= 0x02000000; // WS_EX_COMPOSITED
return handleParam;
}
}
它将我屏幕的整个背景更改为黑色。
但问题仍然存在,有人可以告诉我如何解决这个问题以及我在哪里做错了吗?提前非常感谢。