Back to Devexpress

How to: Save a control's layout to the system registry

windowsforms-1878-common-features-save-and-restore-layouts-how-to-save-a-controls-layout-to-the-system-registry.md

latest1005 B
Original Source

How to: Save a control's layout to the system registry

  • Oct 29, 2020

The following sample code demonstrates a way of saving a view’s layout (in XtraGrid) to a specific system registry path and then restoring it.

You can define absolute and relative registry keys as the parameter. For example, 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 you need to store the layout to another root key.

csharp
string regKey = "DevExpress\\XtraGrid\\Layouts\\MainLayout";
advBandedGridView1.SaveLayoutToRegistry(regKey);
// ...
advBandedGridView1.RestoreLayoutFromRegistry(regKey);
vb
Dim regKey As String = "DevExpress\XtraGrid\Layouts\MainLayout"
AdvBandedGridView1.SaveLayoutToRegistry(regKey)
' ...
AdvBandedGridView1.RestoreLayoutFromRegistry(regKey)