WinForms - Does the DoubleBuffered format control affect this form?

Form has the DoubleBuffered property (bool inherited from Control).

If this parameter is set to true, all controls are placed on the form drawn on the screen in double buffering mode, since it is in the form? Or do you need to worry about your own DoubleBuffered properties?

+3
source share
1 answer

From what I remember, no, double buffering DOES NOT carry child controls. You must install it for each separately. I will google and see if I can find the source to prove / disprove it ...

: : http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic17173.aspx

, . , , DoubleBuffered, :

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);
    }
}

:

    public Form1()
    {
        InitializeComponent();
        this.DoubleBuffered = true;
        foreach (Control control in this.Controls)
        {
            control.EnableDoubleBuferring();
        }
    }
+5

Source: https://habr.com/ru/post/1709104/


All Articles