Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Collapse]Docking Library
   [Expand]Panels and Panel Containers
    Header Buttons
   [Expand]Managing Dock Panels in Code
    Saving and Restoring the Layout of Dock Panels
   [Expand]Examples
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Saving and Restoring the Layout of Dock Panels

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.

Note

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.

Expanded 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\".

Expanded Example 1

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

Note

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).

Expanded 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.

Expanded Example 2

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

Expanded See Also

How would you rate this topic?​​​​​​​