Back to Devexpress

BarManager.RestoreLayoutFromStream(Stream) Method

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

latest3.6 KB
Original Source

BarManager.RestoreLayoutFromStream(Stream) Method

SECURITY-RELATED CONSIDERATIONS

Deserializing layout settings from untrusted resources may create security issues. Review the following help topic for additional information: Safe Deserialization.

Restores the bars’ layout from the specified stream.

Namespace : DevExpress.XtraBars

Assembly : DevExpress.XtraBars.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

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

Parameters

NameTypeDescription
streamStream

A Stream descendant from which the bars’ settings are read. If null ( Nothing in Visual Basic), an exception is raised.

|

Remarks

Use the RestoreLayoutFromStream method to load the bars’ layout from the stream to which the layout was saved via the BarManager.SaveLayoutToStream method.

Note

When restoring a layout during a form load (for instance, in your Form.Load event handler), you may need to call the BarManager.ForceInitialize method prior to the layout restoration. See this method to learn more.

For more information, see Saving and Restoring a Bars Layout Manually.

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

RestoreLayoutFromRegistry

RestoreLayoutFromXml(String)

Save and Restore Layouts of DevExpress controls

BarManager Class

BarManager Members

DevExpress.XtraBars Namespace