As Hans noted, SuspendLayout and ResumeLayout work well in this situation, while also pausing the drawing of the control for the container:
public static class Win32 { public const int WM_SETREDRAW = 0x0b; [DllImport("user32.dll")] public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); public static void SuspendPainting(IntPtr hWnd) { SendMessage(hWnd, WM_SETREDRAW, (IntPtr)0, IntPtr.Zero); } public static void ResumePainting(IntPtr hWnd) { SendMessage(hWnd, WM_SETREDRAW, (IntPtr)1, IntPtr.Zero); } }
Then you can resize the events:
private void Form1_ResizeBegin(object sender, EventArgs e) { tableLayoutPanel1.SuspendLayout(); } private void Form1_ResizeEnd(object sender, EventArgs e) { Win32.SuspendPainting(tableLayoutPanel1.Handle); tableLayoutPanel1.ResumeLayout(); Win32.ResumePainting(tableLayoutPanel1.Handle); this.Refresh(); }
Larstech
source share