现在的位置: 首页 > 综合 > 正文

[控件]DockPanel里如何在一个子窗体里打开另一个子窗体 显示在主窗体中

2013年04月30日 ⁄ 综合 ⁄ 共 536字 ⁄ 字号 评论关闭

在主窗体里设置               
                public   DockPanel   DockPanel
                {
                        get
                        {
                                return   this.dockPanel;
                        }
                }

在要打开新子窗体的子窗体中设置

           
uiConfig   uiCfig   =   new   uiConfig();
if   (((Main_frm)GetTopParent(this)).DockPanel.DocumentStyle   ==   DocumentStyle.SystemMdi)
 {
           uiCfig.MdiParent   =   (Main_frm)GetTopParent(this);
           uiCfig.Show();
}
else
         uiCfig.Show(((Main_frm)GetTopParent(this)).DockPanel);

private Control GetTopParent(Control control)

{

while (control.Parent != null)

{

control = control.Parent;

}

return control;

}

抱歉!评论已关闭.