如何在其windowstate =最大化的mdi容器表单中显示子表单? [英] How to show a child form within a mdi container form which its windowstate= maximized?

查看:145
本文介绍了如何在其windowstate =最大化的mdi容器表单中显示子表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在其windowstate =最大化的mdi容器表单中显示子表单?

How can I show a child form within a mdi container form which its windowstate= maximized ?

当我在加载子表单时(通过单击主表单的菜单项)将以下这些代码放在代码行中时,子表单会失去其父位置,并且不会显示在其父表单中.

when I put these below lines of code when my child form is loading (by clicking on a menu Item of my Main form), the child form loses its parent position and does not show within its parent form.

private void mnuUnit_Click(object sender, EventArgs e)
{
    frmUnit frm = new frmUnit();
    frm.MdiParent = this;
    frm.WindowState = FormWindowState.Maximized;
    frm.Show();
}

推荐答案

您忘记粘贴代码了吗?

要将MDI子窗体显示为最大化,请执行以下操作:

To show an MDI child form as maximized, you do the following:

// This is a method on the MDI parent (IsMdiContainer = true)
private void Button1_Click(object sender, EventArgs e)
{
    var myForm = new MyCustomForm();
    myForm.MdiParent = this;
    myForm.WindowState = FormWindowState.Maximized;
    myForm.Show();
}

这篇关于如何在其windowstate =最大化的mdi容器表单中显示子表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆