Form
has the DoubleBuffered property (bool, inherited from Control).
If this is set to true, are all controls placed on the form drawn to screen in a double buffered fashion by virtue of being on the Form? Or do you need to worry about their own DoubleBuffered properties?
Buffered graphics can reduce or eliminate flicker that is caused by progressive redrawing of parts of a displayed surface.
Double buffering uses a memory buffer to address the flicker problems associated with multiple paint operations. When double buffering is enabled, all paint operations are first rendered to a memory buffer instead of the drawing surface on the screen.
From what I remember, no, double buffering does NOT carry over to child controls. You need to set it for each one individually. I'll google it and see if I can find a source to prove / disprove this...
EDIT: Found this: http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic17173.aspx
Just thought of a quick hack to get around this. Basically, use reflection to get the "DoubleBuffered" property, and then set it:
public static class Extensions
{
public static void EnableDoubleBuferring(this Control control)
{
var property = typeof(Control).GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
property.SetValue(control, true, null);
}
}
Then, in your form code, do something like this:
public Form1()
{
InitializeComponent();
this.DoubleBuffered = true;
foreach (Control control in this.Controls)
{
control.EnableDoubleBuferring();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With