Partilhar via


How to: Reduce Graphics Flicker with Double Buffering for Forms and Controls

For most applications, the default double buffering provided by the .NET Framework will provide the best results. Standard Windows Forms controls are double buffered by default. You can enable default double buffering in your forms and authored controls in two ways. You can either set the DoubleBuffered property to true, or you can call the SetStyle method to set the OptimizedDoubleBuffer flag to true. Both methods will enable default double buffering for your form or control and provide flicker-free graphics rendering. Calling the SetStyle method is recommended only for custom controls for which you have written all the rendering code.

For more advanced double buffering scenarios, such as animation or advanced memory management, you can implement your own double buffering logic. For more information, see How to: Manually Manage Buffered Graphics.

To reduce flicker

  • Set the DoubleBuffered property to true.

    DoubleBuffered = True
    
    DoubleBuffered = true;
    

- or -

  • Call the SetStyle method to set the OptimizedDoubleBuffer flag to true.

    SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
    
    SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
    

See Also

Reference

DoubleBuffered
SetStyle

Concepts

Double Buffered Graphics

Other Resources

Graphics and Drawing in Windows Forms