windowsforms-devexpress-dot-xtranavbar-dot-navbarcontrol-dot-savetostream-x28-system-dot-io-dot-stream-x29.md
Saves the control’s layout to a stream.
Namespace : DevExpress.XtraNavBar
Assembly : DevExpress.XtraNavBar.v25.2.dll
NuGet Package : DevExpress.Win
public virtual void SaveToStream(
Stream stream
)
Public Overridable Sub SaveToStream(
stream As Stream
)
| Name | Type | Description |
|---|---|---|
| stream | Stream |
A System.IO.Stream object to which the control’s layout is written.
|
Use the SaveToStream method to write the NavBarControl control’s layout to a stream. You can read stored settings from the stream via the NavBarControl.RestoreFromStream method.
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.
The following sample code demonstrates the way in which to save the control layout to a stream and then restore it. The NavBarControl.SaveToStream and NavBarControl.RestoreFromStream 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 for the first control is saved to a stream. The second control restores it. Note that only the layout of groups and links is saved.
Imports System.IO
FileStream outFile = new FileStream("C:\\NavBarLayout", FileMode.Create);
navBarControl1.SaveToStream(outFile);
outFile.Close();
FileStream inFile = new FileStream("C:\\NavBarLayout", FileMode.Open);
navBarControl2.RestoreFromStream(inFile);
inFile.Close();
Dim OutFile As New System.IO.FileStream("C:\NavBarLayout", IO.FileMode.Create)
NavBarControl1.SaveToStream(OutFile)
OutFile.Close()
Dim InFile As New System.IO.FileStream("C:\NavBarLayout", IO.FileMode.Open)
NavBarControl2.RestoreFromStream(InFile)
InFile.Close()
See Also