Back to Devexpress

BarManager.SaveLayoutToStream(Stream) Method

windowsforms-devexpress-dot-xtrabars-dot-barmanager-dot-savelayouttostream-x28-system-dot-io-dot-stream-x29.md

latest4.3 KB
Original Source

BarManager.SaveLayoutToStream(Stream) Method

Saves the bars’ layout to a stream.

Namespace : DevExpress.XtraBars

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
public virtual void SaveLayoutToStream(
    Stream stream
)
vb
Public Overridable Sub SaveLayoutToStream(
    stream As Stream
)

Parameters

NameTypeDescription
streamStream

A Stream descendant to which the bars’ layout is written.

|

Remarks

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.

Example

The following code demonstrates how to write and read a BarManager’s state to/from memory using the System.IO.MemoryStream class.

csharp
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);
vb
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

SaveLayoutToRegistry

SaveLayoutToXml(String)

Id

Saving and Restoring a Bars Layout Automatically

Saving and Restoring a Bars Layout Manually

Save and Restore Layouts of DevExpress controls

BarManager Class

BarManager Members

DevExpress.XtraBars Namespace