This is a migrated thread and some comments may be shown as answers.

Add Form to ToolWindow after calling RadDock.LoadFromXml

7 Answers 330 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Moe
Top achievements
Rank 1
Moe asked on 29 Jul 2010, 11:59 PM
In my app I have 3 tool windows docked right/left/bottom respectively and I have one doc window in the middle. Our app support multiple display (different dock windows) where users can switch between display. I persisted each display settings in a separate xml file. My issue is how can I add me forms to the docked window/document after I load the proper xml setting file?

7 Answers, 1 is accepted

Sort by
0
Bernd Mueller
Top achievements
Rank 1
answered on 30 Jul 2010, 11:42 AM
That should be possible with the normal DockControl function:

RadDock1.DockControl(new RadForm(), UI.Docking.DockPosition.Fill, UI.Docking.DockType.Document)

 

0
Nikolay
Telerik team
answered on 06 Aug 2010, 03:47 PM
Hello Mohamed,

Indeed, you can dock a Form in RadDock by calling the DockControl method. However, this method will create a new instance of DockWindow.

In order to host a Form in an existing DockWindow (which actually should be a HostWindow) you should call the LoadContent method of the HostWindow:
((HostWindow)this.radDock1.DockWindows[0]).LoadContent(formInstance);

I hope this helps.

Kind regards,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Sari
Top achievements
Rank 1
answered on 17 Oct 2011, 01:45 PM
Hello Nikolay,
((HostWindow)this.radDock1.DockWindows[0]).LoadContent(formInstance);
Not work if radDock1.DockWindows[0]) is Telerik.WinControls.UI.Docking.ToolWindow.
error System.InvalidCastException
0
Nikolay
Telerik team
answered on 20 Oct 2011, 11:25 AM
Hi Sari,

If you use the API suggested above, the LoadContent method will be available, because the DockControl method creates windows of type HostWindow. In case you want to load a Form in a ToolWindow, you should use the following API:

Form f = new Form();
f.Show();
 
f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
f.TopLevel = false;
f.Dock = DockStyle.Fill;
this.radDock1.DockWindows[0].Controls.Add(f);

I hope this helps.
Kind regards,
Nikolay
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Sari
Top achievements
Rank 1
answered on 20 Oct 2011, 02:22 PM

Hello Nikolay,

I use the LoadContent metod. The LoadContent metod create the ToolWindow.
1. I have an application with mdi forms.
2. If create the mdi form that dockcontrol create document(host window)
3. If  this host window is make docked, and then floating, that after radDock1.SaveToXml radDock1.LoadFromXml radDock created the host window
4. !!! If  this host window is make floating immediately, that after radDock1.SaveToXml radDock1.LoadFromXml radDock created the tool window

Therefore, there was a problem adding a form to an existing tool window.

Thanks for your help

0
Sari
Top achievements
Rank 1
answered on 21 Oct 2011, 06:48 AM

Hello Nikolay,

 

Not work
f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
 
0
Nikolay
Telerik team
answered on 21 Oct 2011, 02:57 PM
Hi Sari,

In regards to your last comment, the FormBorderStyle property is a property of the standard Microsoft Form object. Therefore, if your point concerns complication, this property should always allow you to compile your project. Please note the the 'f' variable of of type Form. If this is not you have meant by saying that FormBorderStyle property does not work, I would kindly ask you to provide us with additional details about your case. As a general recommendation, I would kindly ask you to be more descriptive when you are trying to explain an issue. An explanation that is short of details may be associated with a huge number of scenarios and we may not be aware of which one exactly is yours. Therefore, a complete description of a case will allow both sides to help each other and as a result your will get a quicker and more accurate response. Thank you for your cooperation and understanding.

As to the second to last message, I am not sure that I understand the meaning of the following sentence:
"I use the LoadContent metod. The LoadContent metod create the ToolWindow." The LoadContent method loads controls inside the content area of a HostWindow. This method can't create any type of a DockWindow, so I suppose that you mean the DockControl method.

Please note that in general, the DockControl method is not supposed to be used with MDI forms. The API that you should use in the MDI scenario is described here.

Let's say that you dock your forms thanks to the DockControl method instead of the MDI API. If I understand your case correctly, you first make one of the DockWindows float. Then you save the layout and try to load it afterwards. In this case all the created DockWindows should be of type HostWindows. I am attaching a sample project which demonstrates how this scenario works.

In case you need further assistance, please open a new support ticket and send us a sample project which demonstrates your scenario. In addition, describe the exact steps that we should follow in your project and the exact goal that you want to achieve. This will allow us to assist you further.

Greetings,
Nikolay
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Tags
Dock
Asked by
Moe
Top achievements
Rank 1
Answers by
Bernd Mueller
Top achievements
Rank 1
Nikolay
Telerik team
Sari
Top achievements
Rank 1
Share this question
or