Back to Devexpress

How to: Save a View's Layout to and Restore it from the Registry

windowsforms-3043-controls-and-libraries-data-grid-examples-miscellaneous-how-to-save-a-views-layout-to-and-restore-it-from-the-registry.md

latest1.1 KB
Original Source

How to: Save a View's Layout to and Restore it from the Registry

  • Aug 01, 2019

Tip

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

The following example saves the layout of the GridControl.MainView to the system registry and then restores it. The full path for the layout in the registry will be: HKEY_CURRENT_USER\DevExpress\XtraGrid\Layouts\MainLayout

csharp
string regKey = "DevExpress\\XtraGrid\\Layouts\\MainLayout";
    gridControl1.MainView.SaveLayoutToRegistry(regKey);

    //...

    gridControl1.MainView.RestoreLayoutFromRegistry(regKey);
vb
Dim regKey As String = "DevExpress\XtraGrid\Layouts\MainLayout"
    gridControl1.MainView.SaveLayoutToRegistry(regKey)

    '...

    gridControl1.MainView.RestoreLayoutFromRegistry(regKey)