Skip to main content

BarManager.SaveLayoutToStream(Stream) Method

Saves the bars’ layout to a stream.

Namespace: DevExpress.XtraBars

Assembly: DevExpress.XtraBars.v22.2.dll

NuGet Package: DevExpress.Win.Navigation


public virtual void SaveLayoutToStream(
    Stream 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.


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();
    //set the stream position to the beginning
    stream.Seek(0, System.IO.SeekOrigin.Begin);


    //set the stream position to the beginning
    stream.Seek(0, System.IO.SeekOrigin.Begin);
See Also