Skip to main content
Bar

BarManager.SaveLayoutToRegistry(String) Method

Saves the bars’ layout to the specified system registry path.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v23.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public virtual bool SaveLayoutToRegistry(
    string path
)

Parameters

Name Type Description
path String

The registry path to save the bars’ layout to.

Returns

Type Description
Boolean

true if the bars’ layout has been saved to the specified system registry path; otherwise, false.

Remarks

After the bars’ layout has been saved to the system registry using the SaveLayoutToRegistry method it can then be restored using the BarManager.RestoreLayoutFromRegistry method.

The Bar Manager allows you to automatically store the layout of its bars to the registry when the form is closed and restore the layout when the form is loaded. The BarManager.RegistryPath property specifies where the bars’ settings are stored in this case. Automatic saving/loading of bar layout is enabled if the BarManager.AutoSaveInRegistry property is set to true.

Bar items within the Bar Manager and within the stored layout are identified by unique identifiers specified by the BarItem.Id property. To correctly save the layout, ensure that this property is set to a unique value for each bar item. For items created at design time, the BarItem.Id properties are initialized automatically. For items created in code, you need to manually initialize their BarItem.Id properties.

For more information, see Saving and Restoring a Bars Layout Manually.

Tip

You can utilize the Persistence Behavior or Workspace Manager component to save and restore layouts for all supported DevExpress controls at once.

Example

The following code demonstrates how to write and read a BarManager’s state to/from the system registry. The full path for the bars layout will be: HKEY_CURRENT_USER\DevExpress\XtraBars\States\MainState.

    string regKey = "DevExpress\\XtraBars\\States\\MainState";
    barManager1.SaveLayoutToRegistry(regKey);

    //...

    barManager1.RestoreLayoutFromRegistry(regKey);
See Also