日期:2014-05-17  浏览次数:21175 次

Winform子窗口最大化后和主窗口重叠问题
MDI子窗口最大化后,再点击MDI父窗口的还原,两者的标题栏就合在一起了,然后子窗口就没办法还原了,怎么办?
关键是出现这种情况后,会导致我某些DGV单元格无法编辑。上图:
初始界面:

子窗口最大化后的界面:

父窗口还原后的最终界面:


打开子窗口的代码:
private void buttonItem11_Click(object sender, EventArgs e)
        {
            foreach (Form f in this.MdiChildren)
            {
                if (f is WL_SaleCost.SC_SalesQuotation)
                {
                    f.Activate();
                    SetParent((int)f.Handle, (int)this.Handle);
                    return;
                }
            }
            WL.WL_SaleCost.SC_SalesQuotation WF = new WL_SaleCost.SC_SalesQuotation();
            //权限
            if (PropertyClass.IsAdmin != 1)
            {
                string qx = cUse.UserAssignRight(WF);
                if (qx == "没有权限")
                {
                    MessageBoxEx.Show("没有权限,请联系系统管理员!", "软件提示");
                    return;
                }
            }
            //open form
            WF.MdiParent = this;
            WF.Show();
            SetParent((int)WF.Handle, (int)this.Handle);

------解决方案--------------------
设置MdiParent属性了,还要设置SetParent干嘛?去掉SetParent((int)WF.Handle,(int)this.Handle);这行试试
------解决方案--------------------
MaximumSize?
------解决方案--------------------
如果你不想子窗口覆盖到父窗口,就把子窗口的MaximumSize设成父窗口的Height*N%不就可以了吗?

在属性里设~
------解决方案--------------------
你的问题不就是最大化之后会BUG嘛,不让他最大化不就完了!看你纠结的