停靠一个WinForm在另一个的WinFormWinForm

2023-09-03 07:43:37 作者:宅女

我停留在一个问题,是关于同样的问题,老答案不是很足够新,所以我认为这会是好再问。 我的问题是:我怎么能停靠一个形式里面另一种形式?难道是比较合适的使用面板和形式呢?是第一个选项甚至可能吗? 先谢谢了。

I'm stuck at a problem and the old answers regarding the same problem are not quite recent enough so i thought it'd be okay to ask again. My question is: How can i dock one form inside another form? Would it be more appropriate to use a Panel and a Form instead? Is the first option even possible? Thanks in advance.

推荐答案

创建2种形式,Form 1和Form。设置窗体2的顶层属性设置为false。在形式上负荷Form1中添加code

Create 2 forms, Form1 and Form2. Set TopLevel property of Form2 to false. In form load for Form1 add code

private void Form1_Load(object sender, EventArgs e)
{
    Form2 frm2 = new Form2();
    frm2.Show();

    this.Controls.Add(frm2);
}

这将包括窗口2在Form1,你就必须设置窗口2属性,如果要删除标题栏,使形式更象一个小组。

This will include form2 in form1, you then have to set properties on form2 if you want to remove the title bar to make the form more like a Panel.