c# 子窗体打开或者切换就最大化

“用MDI方式打开一个子窗口体后,总是不能最大化显示,明明子窗口体的WindowState设置为Maximized?”,相信有很多人会遇到这的样问题,请按下面的方法设置即可使MDI子窗体最大化:
1、把父窗体的IsMdiContainer设置为True;
2、把子窗体的WindowState设置为Normal;
3、在父窗体中用下面的方法打开子窗体

private void testToolStripMenuItem_Click(object sender, EventArgs e)

        {
            // 关闭活动的子窗体
            Form activeChild = this.ActiveMdiChild;
            while (activeChild != null)
            {
                activeChild.Close();
                activeChild = this.ActiveMdiChild;
            }
            // 打开新的子窗体
            Forggg test = new Forggg();
            test.MdiParent = this;
            test.WindowState = FormWindowState.Maximized;
            test.Show();

            // 或者打开新的子窗体

           frmDiYaSystemDiagram = FrmSystemDiagramLow.Instince();
           frmDiYaSystemDiagram.MdiParent = this;
           frmDiYaSystemDiagram.WindowState = FormWindowState.Maximized;
           frmDiYaSystemDiagram.Show();

        }

posted on 2018-08-17 14:03  编程笑笑生  阅读(1207)  评论(0编辑  收藏  举报

导航