Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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);


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)
Posted
Updated 6-Jul-16 20:39pm

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:-
C#
Form childFrm = this.MdiChildren.First(frm => frm.Name.Equals("findFormName"));
            if (childFrm != null)
            {
                childFrm.Hide();
            }

I hope this will help you..
 
Share this answer
 
Comments
Prakash1206 27-Jun-16 5:05am    
HiThanks for answering,
i couldn't follow second question's answer. i'm coding in C++/Cli.
so don't know about '=>' operator, i don't think its available in this language. also i cannot see 'First' function from MdiChildren in Visual studio.
Could you please explain your code bit more? so that i will try to convert to C++/Cli
Thanks & Regards
JayantaChatterjee 27-Jun-16 6:00am    
sorry, code, I didn't see the C++ tag...
this is not in C++ code,its in C#.net...
you can get the help click this link:-

https://www.google.co.in/?gfe_rd=cr&ei=ctZwV-zoGtDk8Aey85MY&gws_rd=ssl#q=dockpanel+suite+documentation
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.

C++
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();
		 }
		}
	}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900