Control Nesting Limits in WinForms

余生长醉 提交于 2019-12-20 02:34:37

问题


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;
        }
    }
}

回答1:


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



来源:https://stackoverflow.com/questions/18060438/control-nesting-limits-in-winforms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!