There is such a Windows style in the SDK header file: WS_EX_COMPOSITED, this style enables Windows Forms to enable double buffering on all forms and its child controls.
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}
What's said on the Internet is wrong.
public Form1()
{
InitializeComponent();
base.SetStyle(
ControlStyles.OptimizedDoubleBuffer
| ControlStyles.ResizeRedraw
| ControlStyles.Selectable
| ControlStyles.AllPaintingInWmPaint // 禁止擦除背景.
| ControlStyles.UserPaint
| ControlStyles.SupportsTransparentBackColor
| ControlStyles.DoubleBuffer // 双缓冲
,true);
}