[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [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
  [Collapse]Ribbon, Bars and Menu
     MDI Merging
    [Expand]Bar Manager Designer
    [Collapse]Runtime Customization and Layout Management
      Runtime Customization
      How To: Organize Bar Items into Categories
      Saving and Restoring a Bars Layout Automatically
      Saving and Restoring a Bars Layout Manually
      Layout Options and Customization Events
      Specifics of Bars Layout Calculation
    [Expand]Appearance and Hotkeys
   [Expand]Popup Menus
    Radial Menu
   [Expand]Common Features
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst 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]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Saving and Restoring a Bars Layout Manually

The bars' layout can be automatically saved by the BarManager, or manually by the user. The layout can only be automatically saved/restored if the Bar Manager belongs to a System.Windows.Forms.Form class instance. Otherwise, the layout should be saved/loaded manually by a user. This topic describes the various ways to perform this task.

Please refer to the Saving and Restoring a Bars Layout Automatically topic, for information on how to save/restore the bars' layout automatically. For information on saving/restoring the layout of dock panels, see Saving and Restoring the Layout of Dock Panels.

For information on saving the layout of bar commands within the Ribbon Quick Access Toolbar, see this link.

The bar items within the BarManager, and within the stored layout, are identified by the values of their BarItem.Id properties. For items created at design time, the BarItem.Id properties are initialized automatically. For items created via code, initialize their BarItem.Id properties manually to allow the layout of the bars to be correctly saved and restored. To set the BarItem.Id property's value, the BarManager.GetNewItemId method can be used.


Do not restore the layout of bars until the Bar Manager is completely initialized. Typically, you need to restore the layout within the Form.Load event.


When saving/loading the layout of bars and using the merging feature, take note of the following. If you saved the layout while bars have been merged, do not load this layout after the bars have been unmerged. Typically, you need to save and load the layout of bars while the bars are unmerged.

Expanded How to Save the Bars' Layout to a System Registry

The bars' layout can be saved to the system registry by calling the BarManager's BarManager.SaveLayoutToRegistry method. You can then restore these settings using the BarManager.RestoreLayoutFromRegistry method.

You can define absolute and relative registry keys as the parameter. For instance, specifying "Software\MyCompany\MyProject" as a partial key will result in saving the settings to the "HKEY_CURRENT_USER\Software\MyCompany\MyProject" path. You can also specify the entire key if, for instance, you need to store the layout to another root key. The following sample code shows how the bars' layout can be saved to the specified system registry path and then restored.

Expanded How to Save the Bars' Layout to a Stream

The bars' layout settings can also be written to a stream. Call the BarManager's BarManager.SaveLayoutToStream method for this purpose. You can then read the saved settings using the BarManager.RestoreLayoutFromStream method. The example below shows how this can be done. The sample code below saves the layout settings to a memory stream, and then restores them.

Expanded How to Save the Bars' Layout to an XML File

If it is necessary to save the bars' layout to an XML file, call the BarManager's BarManager.SaveLayoutToXml method. The BarManager.RestoreLayoutFromXml method restores previously saved layout settings from the XML file. The following sample code shows how to save and load the bars' layout at runtime.

A layout previously saved to an XML file can also be loaded and applied to bars at design time, using the XtraBars Editor provided. Please see the Saving And Restoring Layout Pages topic, for information.

Expanded See Also

Is this topic helpful?​​​​​​​