Question

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:

Exception

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;
        }
    }
}
Était-ce utile?

La solution

According to Raymond Chen you cannot, it was a deliberate decision on the part of the windows executive developers.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top