Back to Devexpress

NavBarControl.SaveToRegistry(String) Method

windowsforms-devexpress-dot-xtranavbar-dot-navbarcontrol-dot-savetoregistry-x28-system-dot-string-x29.md

latest4.4 KB
Original Source

NavBarControl.SaveToRegistry(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.XtraNavBar

Assembly : DevExpress.XtraNavBar.v25.2.dll

NuGet Package : DevExpress.Win

Declaration

csharp
public virtual bool SaveToRegistry(
    string path
)
vb
Public Overridable Function SaveToRegistry(
    path As String
) As Boolean

Parameters

NameTypeDescription
pathString

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

|

Returns

TypeDescription
Boolean

true if the layout was successfully saved; otherwise false.

|

Remarks

Use the SaveToRegistry method to save the NavBarControl‘s layout to the system registry. You can restore these settings via the NavBarControl.RestoreFromRegistry 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".

Note

To allow a layout to be correctly saved and restored, ensure that all nav bar groups and items created at runtime have their names (the Name property) specified.

Example

The following sample code demonstrates a way in which to save control layout to the registry and then restore it. The NavBarControl.SaveToRegistry and NavBarControl.RestoreFromRegistry methods are used for this purpose.

The image below displays two NavBarControl controls before and after code execution. Note that the second control is initially empty (it doesn’t contain any groups and items). Layout information of the first control is saved to the registry. The second control restores it. Note that only the layout of groups and links is saved.

csharp
navBarControl1.SaveToRegistry(
  "HKEY_LOCAL_MACHINE\\SOFTWARE\\DevExpress Inc\\NavBarLayout");
navBarControl2.RestoreFromRegistry(
  "HKEY_LOCAL_MACHINE\\SOFTWARE\\DevExpress Inc\\NavBarLayout");
vb
NavBarControl1.SaveToRegistry( _
  "HKEY_LOCAL_MACHINE\SOFTWARE\DevExpress Inc\NavBarLayout")
NavBarControl2.RestoreFromRegistry( _
  "HKEY_LOCAL_MACHINE\SOFTWARE\DevExpress Inc\NavBarLayout")

See Also

RestoreFromRegistry(String)

SaveToStream(Stream)

SaveToXml(String)

OptionsLayout

StoreAppearance

Save and Restore Layout

NavBarControl Class

NavBarControl Members

DevExpress.XtraNavBar Namespace