日期:2014-05-18  浏览次数:21009 次

C# 一个MDI窗体怎样在加载子窗体时,使子窗体为最大化,我的windowstate属性设置了的啊
C#   一个MDI窗体怎样在加载子窗体时,使子窗体为最大化,我的windowstate属性设置了的啊。。。代码如下  
click的
                          Addofficer   Addofficer1   =   new   Addofficer();
                        Addofficer1.MdiParent   =   this;


                        Addofficer1.Show();
Addofficer1的:
                      this.WindowState   =   FormWindowState.Maximized;
                        this.FormBorderStyle   =   FormBorderStyle.None;  
                        this.ControlBox   =   false;
                        this.Menu   =   null;

------解决方案--------------------
/// <summary>
///打开子窗体
/// </summary>
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).slblOperate.Text = ff.Text;

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

调用 openChildrenWindow(this, new form());//this parentWindow,form要打开的窗体