在主窗体里设置
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;
}
本文介绍了如何在主窗体中根据不同文档样式展示子窗体的方法。通过检查主窗体的DockPanel属性,可以判断是否使用系统MDI风格,并据此决定子窗体的MdiParent属性设置,实现子窗体的正确显示。
730

被折叠的 条评论
为什么被折叠?



