How to avoid flicker while adding controls to a Panel

  • Thread starter Thread starter Alessandro Fragnani
  • Start date Start date
A

Alessandro Fragnani

Hi,

I would like to know how to avoid flicker while adding controls to a
panel. I couldn´t find any kind of "BeginUpdate/EndUpdate" on it.

Thanks in advance

Alessandro
 
You can use SuspendLayout() and ResumeLayout().

Also, try inheriting Panel and creating a custom class. Set the class style to use DoubleBuffering. It reduces flicker.

public class MyPanel : System.Windows.Forms.Panel
{
public MyPanel()
{
SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true);
SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true);
SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);
}
}
 
Back
Top