public static void openChildrenWindow(System.Windows.Forms.Form parentWindow, System.Windows.Forms.Form childrenWindow)
        {
            foreach (System.Windows.Forms.Form ff in parentWindow.MdiChildren)
            {
                //如果子窗体存在,激活子窗体
                if (ff.Name == childrenWindow.Name)
                {
                    ff.Activate();
                    ff.Size = ff.Parent.Size;
                    ff.WindowState = System.Windows.Forms.FormWindowState.Maximized;
                    //((frmMain)parentWindow).s slblOperate.Text = ff.Text;

                    return;
                }
            }
            parentWindow.IsMdiContainer = true;
            childrenWindow.MdiParent = parentWindow;
            childrenWindow.WindowState = System.Windows.Forms.FormWindowState.Maximized;
            //parentWindow.ActiveMdiChild = childrenWindow;
            childrenWindow.Show();
        }

调用:

    openChildrenWindow(this, new Form2());  //form2需要打开的窗体  

相关文章:

  • 2021-08-29
  • 2021-08-07
  • 2021-06-07
  • 2022-12-23
  • 2021-06-23
猜你喜欢
  • 2022-12-23
  • 2022-01-03
  • 2021-09-29
  • 2021-07-21
  • 2021-12-26
  • 2022-01-10
相关资源
相似解决方案