R – Enabling Double Buffering

doublebufferedvisual-studio-2008winforms

I've seen the following code to enable double buffering on a winform:

// Activates double buffering 
this.SetStyle(ControlStyles.DoubleBuffer |
   ControlStyles.OptimizedDoubleBuffer |
   ControlStyles.UserPaint |
   ControlStyles.AllPaintingInWmPaint, true);
this.UpdateStyles();

Is this different in any way from simply setting Form.DoubleBuffering = true?

Best Answer

Control.DoubleBuffering performs

SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, value);

so your code sets ControlStyles.UserPaint as well (which probably has no effect at this point).

Related Topic