在SDK头文件中有这样一个Windows样式:WS_EX_COMPOSITED,这个样式可使Windows Forms启用双缓冲于所有窗体以及其子控件。
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}
网上说的不对。
public Form1()
{
InitializeComponent();
base.SetStyle(
ControlStyles.OptimizedDoubleBuffer
| ControlStyles.ResizeRedraw
| ControlStyles.Selectable
| ControlStyles.AllPaintingInWmPaint // 禁止擦除背景.
| ControlStyles.UserPaint
| ControlStyles.SupportsTransparentBackColor
| ControlStyles.DoubleBuffer // 双缓冲
,true);
}