[英]MDI parent size to fit MDI child form
I want the MDI parent to auto-size the child form so it fits inside without scroll bars. 我希望MDI父项自动调整子表单的大小,使其适合内部而不需要滚动条。 Can someone provide some code?
有人能提供一些代码吗?
I have used this to differentiate the size of the parent and the child and add it to the size of the parent so I would get a fit. 我已经用它来区分父级和子级的大小,并将其添加到父级的大小,这样我就可以得到一个合适的大小。 But it's so manual and takes too long to make.
但它是如此手动,需要很长时间才能完成。
void MDICentertoScreen(Form z,Size addedsize)
{
foreach (Form f in this.MdiChildren)
{
f.Close();
}
z.StartPosition = FormStartPosition.CenterScreen;
z.MdiParent = this;
// this.Size = Size.Add(z.Size, addedsize);
this.CenterToScreen();
z.Show();
}
Maybe this solve your problem: 也许这可以解决你的问题:
form.MdiParent = this;
form.Dock=DockStyle.Fill;
form.Show();
Below is what I have used to solve this problem: 以下是我用来解决这个问题的方法:
this.Dock = DockStyle.Fill; this.Dock = DockStyle.Fill;
this.WindowState = FormWindowState.Maximized; this.WindowState = FormWindowState.Maximized;
That is, It solves my problem. 也就是说,它解决了我的问题。 Good luck!
祝好运!
This is what I use: 这是我使用的:
Form form = new Form();
form.MdiParent = this;
form.Show()
form.WindowState = FormWindowState.Maximized;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.