panel1.SuspendLayout(); // add or remove controls from panel1 panel1.ResumeLayout();
using (var graphics = panel1.CreateGraphics()) { panel1.SuspendLayout(); // draw on panel1 using the graphics object panel1.ResumeLayout(false); }In this example, the SuspendLayout method is used before drawing on the panel using the CreateGraphics method. The ResumeLayout method is called with the false parameter to indicate that layout logic should not be performed immediately after the changes are made. The System.Windows.Forms namespace is part of the .NET Framework Class Library.