Back to Devexpress

How to: Save the layout of bars to a stream

windowsforms-5419-controls-and-libraries-ribbon-bars-and-menu-examples-bars-how-to-save-the-layout-of-bars-to-a-stream.md

latest1.3 KB
Original Source

How to: Save the layout of bars to a stream

  • Jan 18, 2019

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.

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)