Back to Devexpress

BaseView.SaveLayoutToRegistry(String) Method

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-baseview-dot-savelayouttoregistry-x28-system-dot-string-x29.md

latest4.5 KB
Original Source

BaseView.SaveLayoutToRegistry(String) Method

SECURITY-RELATED CONSIDERATIONS

Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.

Saves a View’s layout to a system registry path.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public void SaveLayoutToRegistry(
    string path
)
vb
Public Sub SaveLayoutToRegistry(
    path As String
)

Parameters

NameTypeDescription
pathString

A string value specifying the system registry path to which the layout is saved.

|

Remarks

Use the SaveLayoutToRegistry method to save the View’s layout to the system registry. You can then restore these settings using the BaseView.RestoreLayoutFromRegistry method.

You can define whole and partial registry keys as the parameter. For instance, specifying “Software\MyCompany\MyProject" as a partial key will result in saving settings to the “HKEY_CURRENT_USER\Software\MyCompany\MyProject" path. You can also specify the entire path if you need to store the layout at another root key, for instance. An example is the “HKEY_LOCAL_MACHINE\Software\MyCompany\MyProject" registry path.

The ColumnView.OptionsLayout property controls which settings should be saved to the registry.

Important

The Document Manager identifies its child documents by names of controls hosted within these documents. Thus, it is recommended that you set unique names for these controls. Failure to comply with this recommendation will result in an exception for certain scenarios (e.g., saving and restoring a View layout by using the SaveLayoutToRegistry method).

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 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)

See Also

RestoreLayoutFromRegistry

SaveLayoutToStream

SaveLayoutToXml

OptionsLayout

LayoutUpgrade

Save and Restore Grid Layout

Save and Restore Layouts of DevExpress controls

BaseView Class

BaseView Members

DevExpress.XtraGrid.Views.Base Namespace