I'm creating my form's controls in the runtime, and for some reason, I need the depth to be more than 49 nested controls (i.e. control is contained in another one).
but the following error appears:
How can I add more controls nested in each other ?
Here is a little piece of code that may reproduce the error:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Panel lastPanel = panel1;
for (int i = 0; i < 49; i++)
{
Console.WriteLine(i);
Panel newPanel = new Panel();
lastPanel.Controls.Add(newPanel);
lastPanel = newPanel;
}
}
}
According to Raymond Chen you cannot, it was a deliberate decision on the part of the windows executive developers.