简体   繁体   English

Windows Forms - 面板中的 ChildForm 已放大

[英]Windows Forms - ChildForm in panel is zoomed in

So I have this code to show the childform within the panel:所以我有这段代码来显示面板中的子窗体:

private Form activeForm = null;
private void openChildForm(Form childForm)
{
    if (activeForm != null)
    {
        activeForm.Close();
    }
    activeForm = childForm;
    childForm.TopLevel = false;
    childForm.FormBorderStyle = FormBorderStyle.None;
    childForm.Dock = DockStyle.Fill;
    panelChildForm.Controls.Add(childForm);
    panelChildForm.Tag = childForm;
    childForm.BringToFront();
    childForm.Show();
    labelVersion.BringToFront();
}

The size of the panel and form are exactly the same (the form is a bit larger due to the border, but the borderless size is exactly as the panel).面板和表格的尺寸完全一样(表格因为有边框有点大,但无边框的尺寸和面板一模一样)。 But for some reason, it seems like the form zoomes in when I open it and I can't figure it out.但是由于某种原因,当我打开它时,它似乎放大了,我无法弄清楚。

Well the strange thing is: I got it to work now.好吧,奇怪的是:我现在开始工作了。 I went ahead and changed the font of the form to 10 and then back to 8 and now it fits perfectly.我继续将表单的字体更改为 10,然后又改回 8,现在它非常适合。 I don't really understand what happend there but I'm glad I got it to work now.我真的不明白那里发生了什么,但我很高兴我现在可以让它工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM