I've a UserControl
containing a FlowLayoutPanel
. A lot of this control instances are needed to be used in a nested form on the Form
. I found it out that only 15 nested instances can be created! So I decided to check a more simple model of my control out. The model consist of a GroupBox
that contains a Panel
:
Control parent = this;
for (int groupIndex = 0; groupIndex < 100; groupIndex++)
{
GroupBox grp = new GroupBox();
Panel pnl = new Panel();
pnl.Dock = DockStyle.Fill;
pnl.Parent = grp;
grp.Parent = parent;
grp.Size = new Size(parent.Width - 10, parent.Height - 10);
parent = pnl;
}
When groupIndex
reaches to 24, it encounters the Error creating window handle exception. What's the reason for and how to overcome it?
Thanks