Skip to main content

Saving and Restoring the Layout of Dock Panels

  • 3 minutes to read

DevExpress controls allow you to save their layout information to data stores (XML file, stream and system registry) and restore it later. Refer to the following article to learn the common concept: Save and Restore Layouts of DevExpress controls

The layout of dock panels defines how panels are arranged within a form, their positions, sizes and visibilities. This layout can be saved to the system registry, an XML file or a stream.


Instead of saving only the docking layout, you can also use the Workspace Manager component to save and load the layout of your entire application in a centralized way. Refer to this link for details.

Saving the Layout of Dock Panels

To save the layout of dock panels, use the following methods: DockManager.SaveLayoutToRegistry, DockManager.SaveLayoutToStream and DockManager.SaveLayoutToXml. The saved layout can then be restored via the DockManager.RestoreLayoutFromRegistry, DockManager.RestoreLayoutFromStream and DockManager.RestoreLayoutFromXml methods respectively.

The DockManager.SaveLayoutToRegistry method takes the path parameter, which specifies the registry key where settings are saved. You are allowed to define whole and partial registry keys. For instance, if you define a partial key, “Software\MyCompany\MyTool", the full path will be as follows: “HKEY_CURRENT_USER\Software\MyCompany\MyTool". If you wish to store a layout in another root key, you should define the entire path, for instance: “HKEY_LOCAL_MACHINE\Software\MyCompany\MyTool".

Example 1

In the following example, the layout of dock windows is saved to an XML file.

string xmlFile = "c:\\XtraBars\\DockStates\\MainState.xml";
// ...


A DockManager can be used together with the DocumentManager component, which manages the display of documents/windows. The DockManager.SaveLayoutTo… methods allow you to save the layout of dock panels only. To save the layout of documents/windows, use the SaveLayoutTo… methods provided by the DocumentManager.View object (see BaseView.SaveLayoutToRegistry, BaseView.SaveLayoutToXml and BaseView.SaveLayoutToStream).

Saving the Layout of Dock Panels and Bars

When a BarManager resides within the form, the layout of the dock panels can be saved simultaneously with the layout of the bars to the same destination. For this purpose, the dock manager should be assigned to the BarManager.DockManager property. The layouts of dock panels and bars can then be saved automatically or manually.

To save the layouts manually, call the BarManager’s required method (BarManager.SaveToRegistry, BarManager.SaveLayoutToStream or BarManager.SaveLayoutToXml). The layouts can then be restored via the BarManager’s corresponding method. See the Saving and Restoring a Bars Layout Manually document for more information.

The layouts of dock panels and bars can be saved automatically by the Bar Manager to the system registry. The layouts are automatically saved when the form is closed and then restored when the form is opened again. To enable the automatic saving feature, set the BarManager.AutoSaveInRegistry property to true and then specify the registry path via the BarManager.RegistryPath property. For more information, refer to the Saving and Restoring a Bars Layout Automatically document.

Note: when adding a dock manager at design time to a form that already owns a BarManager, the BarManager.DockManager will be initialized automatically. This property is also initialized when adding a Bar Manager at design time to a form that already has a dock manager. If you create a dock manager and (or) Bar Manager via code, the BarManager.DockManager property must be initialized manually.

Example 2

The following example shows how to manually save the layouts of bars and dock windows to the system registry.

barManager1.DockManager = dockManager1;
barManager1.RegistryPath = "XtraBars\\Layouts\\MainLayout";
// ...
See Also