windowsforms-devexpress-dot-xtrabars-dot-barmanager-dot-savelayouttostream-x28-system-dot-io-dot-stream-x29.md
Saves the bars’ layout to a stream.
Namespace : DevExpress.XtraBars
Assembly : DevExpress.XtraBars.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
public virtual void SaveLayoutToStream(
Stream stream
)
Public Overridable Sub SaveLayoutToStream(
stream As Stream
)
| Name | Type | Description |
|---|---|---|
| stream | Stream |
A Stream descendant to which the bars’ layout is written.
|
After the bars’ layout has been saved using the SaveLayoutToStream method it can then be restored using the BarManager.RestoreLayoutFromStream method.
Bar items within the Bar Manager and within the stored layout are identified by unique identifiers specified by the BarItem.Id property. To correctly save the layout, ensure that this property is set to a unique value for each bar item. For items created at design time, the BarItem.Id properties are initialized automatically. For items created in code, you need to manually initialize their BarItem.Id properties.
For more information, see Saving and Restoring a Bars Layout Manually.
Tip
You can utilize the Persistence Behavior or Workspace Manager component to save and restore layouts for all supported DevExpress controls at once.
The following code demonstrates how to write and read a BarManager’s state to/from memory using the System.IO.MemoryStream class.
System.IO.Stream stream = new System.IO.MemoryStream();
barManager1.SaveLayoutToStream(stream);
//set the stream position to the beginning
stream.Seek(0, System.IO.SeekOrigin.Begin);
//...
barManager1.RestoreLayoutFromStream(stream);
//set the stream position to the beginning
stream.Seek(0, System.IO.SeekOrigin.Begin);
Dim stream As System.IO.Stream
stream = New System.IO.MemoryStream()
BarManager1.SaveLayoutToStream(stream)
'set the stream position to the beginning
stream.Seek(0, System.IO.SeekOrigin.Begin)
'...
BarManager1.RestoreLayoutFromStream(stream)
'set the stream position to the beginning
stream.Seek(0, System.IO.SeekOrigin.Begin)
See Also
Saving and Restoring a Bars Layout Automatically
Saving and Restoring a Bars Layout Manually