I'm using "FlowLayoutPanel" to store a complex GUI. This structure contains two types of UserControls:
- "S" Simple U.C (Constant Size)
- "C" Another FlowLayoutPanel that can have those to type as childs.. and so on.
When I have this kind of structure:
1.C
- S
- S
C :
1.s
2.C
1.S 2.S
It takes about 15 sec to render this control, Every time this control visble changes the GUI get stuck for 15+- sec until its render the whole components.
*Note 1: the complex "C" control is auto sized which contains the FlowLayoutPanel. all "inner" "C" components get their height changed when adding childs. the main\master "C" control got a fix size and have scroll bar.
*Note 2: I extended the FlowLayoutPanel to have some double buffered optimizations:
public sealed class FlowLayoutPanelEx : FlowLayoutPanel {
public FlowLayoutPanelEx()
: base()
{
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
protected override void OnScroll(ScrollEventArgs se)
{
this.Invalidate();
base.OnScroll(se);
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // WS_CLIPCHILDREN
return cp;
}
}
}