We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DockingManager Load and Save Dock Staes of controls docked at run time

Thread ID:





68060 Sep 7,2007 08:07 AM UTC Dec 17,2012 11:16 AM UTC WinForms 2
Tags: Tools
Pankaj Gautam
Asked On September 7, 2007 08:07 AM UTC

Problem Statement:
I do have a blank Form with a Syncfusion DockingManager on it in my MainProject of type WindowsApplication. It does have one menustrip which is having the 'Save Dock Layout' and 'Load Dock Layout' options. All other Controls are docked to this Form at run time which essentially belongs to different usercontrol libraries. I need to save and load these controls dock states.

Issues in Implementation:

As per my observation, the DockingManager works as follows:

• Any control which is docked using DockingManager is kept inside the DockingManager's ControlsArray.
• When we save the dock state using AppStateSerializer, it is saved successfully(say in a XML file).
• When we load the dock state, DockingManager applies the dock state to the controls in its ControlsArray.

This works fine as long as DockingManager's ControlsArray is holding the references to the controls whose state is being loaded.

However, as I describe in the problem statement, my Application Starts with a blank Form and I can dock the other controls from other libraries by clicking a button on the main Form.

So the scenario is :

I statrted my application then by pressing a button 'DockControl' on it , I loaded the controls from other libraries onto my Form. Now I chose the 'Save Dock Layout' menu item and it saved the dock state to an XML file.
Now I close my application. When I start again then my application comes up with a blank form and now I chose the ‘Load Dock Layout’ menu item. AppStateSerializer loads the file in which the dock states were saved but since DockingManager’s ControlsArray is having no control at this point , therefore, DockingManager.LoadDockState(appStateSerializer) doesn’t apply the dock states.

A workaround to this issue:

I tried to serialize the controls information separately (i.e. control's type and names) and when my application starts I deserialized the controls information.
Now I instantiated those controls using reflection and tried to populate the DockingManager's ControlsArray. But since ControlsArray is an Array and initially its size is zero so I can not populate this and it gives me the 'ArrayIndex out of bound exception' when I try to assign the reflected controls to DockingManager's ControlsArray.
So this also doesn’t help me and my problem remains unsolved.

Other serious issues:
• If I dock the controls on a blank panel and (remember panel was also docked at run time) so to say the panel is docked onto the main Form and all other controls onto the panel. This way it even doesn't save the docked states.
• If I docked multiple instances of the same type control (say UserControl1, and 4 instances are docked) and saved the dock state. When I load the dock state only one instance is shown with the loaded dock state. So I lost another (3) instances.
Here is the code snippets from my application:

private void saveLayoutsToolStripMenuItem_Click(object sender, EventArgs e)
AppStateSerializer serializer = new AppStateSerializer(SerializeMode.XMLFile, "StateTest");

serializer.PersistNow(); // XML file is created on the disk.


private void loadLayoutsToolStripMenuItem_Click(object sender, EventArgs e)
AppStateSerializer serializer = new AppStateSerializer(SerializeMode.XMLFile, "StateTest");



Going forward, I would also like to know how I can push this dock state to the Database.

Your quick response over these issues will be highly appreciable.


Problem Statement.zip

Mohamed Suhaib Fahad A. [Syncfusion]
Replied On October 2, 2007 04:10 AM UTC

Hi Pankaj,

Thanks for the details. You have also created a DirectTrac incident for the query you have posted. Please carry on with any other queries through that incident itself.

Here are the details,

Query 1 - Using reflection to load the persistence

Like you have mentioned the DockingManager needs the controls in its collection to apply the serialization state. And you have used a controlserializer for maintaining control info seperately. Everything is fine till here. The ControlsArray present in the DockingManager is a readonly collection of docked controls. So use this collection only to iterate over the docked controls that are added in the DockingManager after the SetEnableDocking(..) is called.

All you need to do when initializing the controls as docked controls is to use the following function,


This will add up the required docking parameters for that particular control. After this if you call the LoadDockState(..) function, all the controls should automatically serialize properly.

I have a sample prepared as per your description. Please download it from the following link,


I have not included any heavy controls in this sample. But since DockingManager treats all the objects as Controls, you can load any kind of control in it (inclusive of controls created by any competitor).

Alternate method 2 -

You had also mentioned that clicking on a button from the menu it loads up all the controls and docks it through the DockingManager. You can modularize this function and load all the controls into the DockingManager without docking them to any specific place. And then apply the LoadSerialization(..) function to automatically set the dock of all the controls. Since all the controls are pre-loaded into the DockingManager it will automatically dock it to the respective positions.

Query 2 - Serious issues in docking

For these two issues, i had tried with the sample that i had mentiond in the previous query. I would like to have a simple sample for reproducing this issue. This would help us analyse further.

Query 3 - Saving the persisted state to database.

This depends on the database that you are using. The best way for using the persistence type is "XML". You have various databases that support having data in XML format.

In SQL Server 2005, there is a DataType for xml. You can create a table with your required fields along with this DataType. Use the .NET classes that you would normally use for Adding/Updating or retrieving from the database.

NOTE: Please test the sample with the latest EssentialStudio v5.2.0.25. Please download that from the following link,


Please let me know if you want any more details.


Michael Lohr
Replied On December 17, 2012 11:16 AM UTC

The original post is some years old, but I have the same problem to persist a dynamic
I have a SDI-form with some user controls which are added at runtime.
This composition of user controls should be saved and restored.

Unfortunately your example
is no longer existing and I have problems to follow your solution.

Could you please support me with a working example to save and restore a dynamic GUI.

Thanks for your help,
Michael Lohr


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon