Weifenluo dockpanel套房:嵌入tabcontrol&隐藏浮动表格 [英] Weifenluo dockpanel suite: embed into tabcontrol & hide floating forms
问题描述
我是DockPanel Suite的新手。
我想要实现的是,在Winforms的TabControl中使用Dockpanel组件(使用DocumentStyle = DockingMdi)。
如果我将DocumentStyle设置为DockingWindow或DockingSdi它工作正常,但更少的对接选项
I am new to DockPanel Suite.
what i'm trying to achieve is, having Dockpanel component(with DocumentStyle = DockingMdi) within a TabControl in Winforms.
If i set DocumentStyle to DockingWindow or DockingSdi it works fine, but fewer docking options
SecondForm ^SF = gcnew SecondForm ();
SF->Show(dockPanel1, DockState::Document);
将DocumentStyle设置为DockingMdi我收到运行时错误
WeifenLuo.WinFormsUI.Docking.dll中发生未处理的System.InvalidOperationException类型异常
其他信息:无效父母表格。使用DockingMdi或SystemMdi文档样式时,DockPanel控件必须是主MDI容器窗体的子控件。
i added mf-> Parent =这个;在SF-> Show()之上,我得到一个新的运行时错误说
System.Windows中发生类型为'System.ArgumentException'的未处理异常.Forms.dll
附加信息:顶级控件无法添加到控件中。
我的第二个查询是,如何隐藏浮动表单?
如果所有表单都停靠在DockPanel中,则隐藏功能运行良好,
如果我调用dockpanel1->隐藏();在制作一个浮动形式之后,浮动形式除外,其他一切都将被隐藏
应该有一些解决方法。请分享您的想法
谢谢
我的尝试:
在tabcontrol外放置dockpanel使其工作(DocumentStyle设置为DockingMdi)
setting DocumentStyle to DockingMdi i get an runtime error
An unhandled exception of type 'System.InvalidOperationException' occurred in WeifenLuo.WinFormsUI.Docking.dll
Additional information: Invalid parent form. When using DockingMdi or SystemMdi document style, the DockPanel control must be the child control of the main MDI container form.
i added mf->Parent = this; above SF->Show(), i get a new runtime error saying
An unhandled exception of type 'System.ArgumentException' occurred in System.Windows.Forms.dll
Additional information: Top-level control cannot be added to a control.
My second query is, How to hide floating forms?
if all forms are docked in DockPanel, hide function works well,
if i call dockpanel1->Hide(); after making one form float, except floating form, everything else will be hidden
there should be some workaround for this. please share your thoughts
Thanks
What I have tried:
placing dockpanel outside tabcontrol makes it work (with DocumentStyle set to DockingMdi)
推荐答案
TabControl是一个容器控制不能有顶级控制或MDI(包含多种形式),所以控件不允许你想要做的事情..
第二个问题回答: -
首先找到你的表格然后隐藏表格..
代码是: -
TabControl is a container control which can not have top level control or MDI(which contain multiple forms), so what you are trying to do is not allowed by the control..
Second question's answer:-
first find your form then hide the form..
code is:-
Form childFrm = this.MdiChildren.First(frm => frm.Name.Equals("findFormName"));
if (childFrm != null)
{
childFrm.Hide();
}
我希望这会对你有帮助..
I hope this will help you..
我希望这可以帮助有相同问题的人。dockPanel1 = nullptr;
在这种情况下无效。使用下面的代码,我们可以安全地从dockPanel中删除内容。
I Hope this helps someone with same issue.dockPanel1 = nullptr;
doesn't help in this case. using below code,we can safely remove contents from dockPanel.
if (dockPanel1->DocumentStyle == DocumentStyle::SystemMdi)
{
for each(Form ^form in MdiChildren)
form->Close();
}
else
{
for (int index = dockPanel1->Contents->Count - 1; index >= 0; index--)
{
if (dynamic_cast<idockcontent^>(dockPanel1->Contents[index]) != nullptr)
{
IDockContent ^content = safe_cast<idockcontent^>(dockPanel1->Contents[index]);
content->DockHandler->Close();
}
}
}
这篇关于Weifenluo dockpanel套房:嵌入tabcontrol&隐藏浮动表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!