Skip to main content

How to Persist Layout Between Application Runs

  • 3 minutes to read

The ExpressLayout Control allows you to persist a layout to an INI file, registry, or stream. This topic describes how you can accomplish this automatically between application runs, and how to use a set of specially designed methods to do this manually at arbitrary points in an application.

Layout information stored within external data stores contains the following group and item attributes:

Except for the Name and Hidden properties, the list includes all the settings that can be customized by end-users. These settings are sufficient to restore the layout at any time, provided that the layout control contains the same items and groups as when it was stored. Changes to item or group properties other than those listed above should be persisted manually.

Persisting Layout Information Automatically

The layout control allows you to automatically preserve its data between application runs in an INI file or the system registry. By default, this functionality is disabled. To activate it, you need to specify the destination storage device and location for the information being stored:

  • An INI file. Set the layout control’s OptionsStoring.StoreToIniFile property to True and designate the filename using the OptionsStoring.IniFileName property. You can specify the full path to the file in order to store this file to a specific location, other than the application’s starting folder. You can also use paths relative to the application’s starting folder.

Once these properties are set, the layout information is automatically saved when the layout control is destroyed, and is loaded when the control is created.

Persisting Layout Information Manually

You can save the layout information to an INI file, registry, custom storage or stream at any time by calling a corresponding method:

To restore the layout, call the layout control’s LoadFromIniFile, Container.RestoreFromStorage, LoadFromRegistry (Container.RestoreFromRegistry), LoadFromStream (Container.RestoreFromStream), or Restore method.

End-users can store and restore layout information by clicking the corresponding buttons within the Customization Form.

The following code sample demonstrates how to save the layout information to a specific file and then restore from it.

var
  AFileName: string;
begin
  AFileName := 'layout.ini';
  dxLayoutControl1.SaveToIniFile(AFileName);
  ...
  dxLayoutControl1.LoadFromIniFile(AFileName);
end;
See Also