【问题标题】:Control Nesting Limits in WinForms在 WinForms 中控制嵌套限制
【发布时间】:2013-08-05 14:14:39
【问题描述】:

我在运行时创建表单的控件,出于某种原因,我需要深度超过 49 个嵌套控件(即控件包含在另一个控件中)。

但出现以下错误:

如何添加更多相互嵌套的控件?

这里有一小段代码可能会重现错误:

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

【问题讨论】:

  • “我需要超过 49 个嵌套控件的深度” - 你真的吗?
  • @MitchWheat 嗯嗯确实是的

标签: c# .net windows-forms-designer nested-controls


【解决方案1】:

根据Raymond Chen you cannot 的说法,这是Windows 执行开发人员经过深思熟虑的决定。

【讨论】:

  • 感谢您的确认。我在我们公司应用程序的一个组件中遇到了这个确切的问题。
猜你喜欢
  • 1970-01-01
  • 2021-03-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多