Back to Devexpress

TreeList.SaveLayoutToRegistry(String) Method

windowsforms-devexpress-dot-xtratreelist-dot-treelist-dot-savelayouttoregistry-x28-system-dot-string-x29.md

latest4.1 KB
Original Source

TreeList.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 the control’s layout to the specified system registry path.

Namespace : DevExpress.XtraTreeList

Assembly : DevExpress.XtraTreeList.v25.2.dll

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

Declaration

csharp
public virtual void SaveLayoutToRegistry(
    string path
)
vb
Public Overridable 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 TreeList‘s layout to the system registry. You can restore these settings via a TreeList.RestoreLayoutFromRegistry method call.

The control’s layout is saved to the path specified by the path parameter. You are allowed to define whole and partial registry keys. For instance, if you define a partial key, “Software\MyCompany\MyTool" the full path will be as follows: “HKEY_CURRENT_USER\Software\MyCompany\MyTool". If you wish to store a layout in a different root key, you should define the entire path, for instance: “HKEY_LOCAL_MACHINE\Software\MyCompany\MyTool".

The Tree List options that are saved are identified by the TreeList.OptionsLayout object.

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 sample code demonstrates how to save the layout of the Tree List control to the registry and then restore it. The TreeList.SaveLayoutToRegistry and TreeList.RestoreLayoutFromRegistry methods are used for this purpose.

csharp
string registryPath = "HKEY_LOCAL_MACHINE\\SOFTWARE\\DevExpress Inc\\TreeListLayout";
treeList1.SaveLayoutToRegistry(registryPath);
treeList2.DataSource = treeList1.DataSource;
treeList2.RestoreLayoutFromRegistry(registryPath);
vb
Dim RegistryPath As String = _
  "HKEY_LOCAL_MACHINE\\SOFTWARE\\DevExpress Inc\\TreeListLayout"
TreeList1.SaveLayoutToRegistry(RegistryPath)
TreeList2.DataSource = TreeList1.DataSource
TreeList2.RestoreLayoutFromRegistry(RegistryPath)

See Also

RestoreLayoutFromRegistry

SaveLayoutToStream

SaveLayoutToXml

Save and Restore Layouts of DevExpress controls

TreeList Class

TreeList Members

DevExpress.XtraTreeList Namespace