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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top