Skip to main content

Save and Restore NavBar Settings

  • 3 minutes to read

The NavBar control allows you to save and load its layout. This can be useful, for instance, when you create multiple NavBar controls with the same structure or to restore the default layout.

API Members

The NavBar control allows you to save and restore its layout settings from different storages. The following table describes the NavBar procedures you can call to save and restore settings:

Procedures

Storage

SaveToIniFile and LoadFromIniFile

An INI file

SaveToStream and LoadFromStream

A stream

SaveToRegistry and LoadFromRegistry

A registry path

Stored Information

The save and load procedures save and load the following information:

Note

The procedures save and restore custom style settings only if you pass True as the SaveStyles and LoadStyles parameters.

The save and load procedures do not save and load the following information:

Note

The control sets default style settings of the loaded View if it differs from the current View. Otherwise, the control does not change default styles.

Examples

You can save and load the control’s layout for different tasks. For instance, if you create multiple NavBar controls with the same structure, customize a single control, save its layout to an INI file, and apply saved settings to other controls. The following code saves a NavBar control’s layout to an INI file and applies saved settings to another control:

dxNavBar1.SaveToIniFile('Example.ini', True);
dxNavBar2.LoadFromIniFile('Example.ini', True);

You can also save the control’s settings as the default layout and restore them when needed. The following code shows how to apply layout setting when a form is loaded and save the settings on a button click. The settings are stored in registry.

procedure TForm1.FormCreate(Sender: TObject);
begin
  dxNavBar1.SaveToRegistry('HKEY_LOCAL_MACHINE\SOFTWARE\Developer Express Inc\NavBarLayout', True);
end;

procedure TForm1.cxButton1Click(Sender: TObject);
begin
  dxNavBar1.LoadFromRegistry('HKEY_LOCAL_MACHINE\SOFTWARE\Developer Express Inc\NavBarLayout', True);
end; 

Note

A load procedure call adds and modifies stored groups and does not delete groups created after a save procedure call. You can call a NavBar control’s Groups.Clear procedure before a load procedure call to delete all groups and restore only saved ones.

See Also