Set DoubleBuffered Property [C#]

This example shows how to set protected property Control.Double­Buffered to true. This is useful, if you want to avoid flickering of controls such as ListView (when updating) or Panel (when you draw on it).

All controls have property DoubleBuffered, but this property is protected. Usually you need to create a new class (inherited from the control) and set the protected property. This example shows a little hack. You can use reflection to access non-public methods and properties. See the example.

public static void SetDoubleBuffered(Control control)
  // set instance non-public property with name "DoubleBuffered" to true
      BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
      null, control, new object[] { true });

See also