我想在我的应用程序的拆分容器 Panel2 上添加 12 个小表单。那是一个 4x3 = 12 个表格的网格。
所以在我的应用程序的主窗体中,我添加了一个 SplitContainer 控件。我分别创建了 12 个单独的表单。
要将 12 个表单添加到 splitcontainer,我这样做:
        form1 _form1 = new form1();
        _form1.TopLevel = false;
        this.splitContainer1.Panel2.Controls.Add(_form1);
        _form1.Show();
        ....
        form12 _form12 = new form12();
        _form12.TopLevel = false;
        this.splitContainer1.Panel2.Controls.Add(_form12);
        _form12.Show();
这里的问题是所有表单(form1...form12)都显示在同一个位置(Location),behing form1。所以我必须手动移动和替换每个表单
我想要得到的是一个包含所有 12 个表单的 SplitCONtainer,每个表单都位于彼此不同的特定位置。
因此,当 SplitContainer 调整大小时,所有 12 个表单也都在调整大小,并且当一个表单关闭时,它的速度保持为空,直到一个新表单被放置在那里。
编辑。我在这里编辑以展示我如何解决这个问题
        int _width = this.flowLayoutPanel1.Width;
        int _height = this.flowLayoutPanel1.Height;
        _width = (int)_width / 4;
        _height = (int)_height / 3;
        _form1.TopLevel = false;
        _form1.Width = _width;
        -form1.height = _height;
        _form1.Owner = this;
        _form1.TopLevel = false;
        flowLayoutPanel1.Controls.Add(_form1);
        _form1.Show();
....
_form12.TopLevel = false;
            _form12.Width = _width;
            -form12.height = _height;
            _form12.Owner = this;
            _form12.TopLevel = false;
            flowLayoutPanel1.Controls.Add(_form12);
            _form12.Show();
它可以按我的意愿工作。感谢您将 FlowLayoutPanel 引入 SplitContainer.panel