I have 3 Tablelayouts as nested in my Form, The problem I am facing is the slow redraw when I maximize or minimize the form, I read about the Double Buffered property and found questions regarding double buffer of Tablelayoutpanel, but I don't know How to create subclass of tablelayoutpanel in visual studio and how to add subclass in toolbox?
Asked
Active
Viewed 74 times
-1
-
2If you have more than 50 controls on a form, or use the BackgroundImage property, then the time needed for each to paint themselves becomes noticeable. [Look here](https://stackoverflow.com/a/89125/17034). – Hans Passant Apr 01 '23 at 12:34
-
Hans' method can solve your problem very well. After you try it, you can post the complete solution. If you have any questions about this, you can edit the question. – Jiale Xue - MSFT Apr 03 '23 at 09:45
-
I have to add controls in my main Main form via different User Control Classes, where do I need to add CreateParams CreateParams method, does it need to be called or just place in main form? – Adil Ahmed Apr 03 '23 at 18:09
-
I add CreateParams method in all of my user controls but there is no change, controls are flickers and redraws very slowly – Adil Ahmed Apr 03 '23 at 20:11
1 Answers
0
For the use of CreateParams. It is called automatically when the form is drawn, so there is no need to explicitly call it. You should be able to modify the form's CreateParams property directly.
public Form1()
{
InitializeComponent();
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // WS_EX_COMPOSITED
return cp;
}
}
I'm not sure how long your delay is.
Likely the main cause of the problem is your multiple levels of nesting. You may need to modify how your controls are laid out.
There is another method you can try:
private void Form1_Resize(object sender, System.EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
tableLayoutPanel1.SuspendLayout();
}
else if (WindowState == FormWindowState.Normal || WindowState == FormWindowState.Maximized)
{
tableLayoutPanel1.ResumeLayout(true);
}
}

Jiale Xue - MSFT
- 3,560
- 1
- 6
- 21
-
I have 3 levels of nesting of TableLayoutPanels, Can you please explain "You may need to modify how your controls are laid out" – Adil Ahmed Apr 06 '23 at 18:23