Back to Devexpress

TreeList.RestoreLayoutFromStream(Stream) Method

windowsforms-devexpress-dot-xtratreelist-dot-treelist-dot-restorelayoutfromstream-x28-system-dot-io-dot-stream-x29.md

latest3.9 KB
Original Source

TreeList.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.

Loads the control’s layout from a stream.

Namespace : DevExpress.XtraTreeList

Assembly : DevExpress.XtraTreeList.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList

Declaration

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

Parameters

NameTypeDescription
streamStream

A System.IO.Stream object from which the control’s settings are read.

|

Remarks

Use the RestoreLayoutFromStream method to load the control’s layout from a stream to which a layout was saved via the TreeList.SaveLayoutToStream method call.

The Tree List options that are restored are identified by the TreeList.OptionsLayout object.

Note

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

Example

The following sample code saves layout of the Tree List control to a file stream and then restores it. The TreeList.SaveLayoutToStream and TreeList.RestoreLayoutFromStream methods are used for this purpose.

csharp
string fileName = "C:\\TreeListLayout";
System.IO.FileStream outFile = new System.IO.FileStream(fileName, System.IO.FileMode.Create);
treeList1.SaveLayoutToStream(outFile);
outFile.Close();
treeList2.DataSource = treeList1.DataSource;
System.IO.FileStream inFile = new System.IO.FileStream(fileName, System.IO.FileMode.Open);
treeList2.RestoreLayoutFromStream(inFile);
inFile.Close();
vb
Dim FileName As String = "C:\TreeListLayout"
Dim OutFile As New System.IO.FileStream(FileName, System.IO.FileMode.Create)
TreeList1.SaveLayoutToStream(OutFile)
OutFile.Close()
TreeList2.DataSource = TreeList1.DataSource
Dim inFile As New System.IO.FileStream(FileName, System.IO.FileMode.Open)
TreeList2.RestoreLayoutFromStream(inFile)
inFile.Close()

See Also

SaveLayoutToStream

RestoreLayoutFromRegistry

RestoreLayoutFromXml

Save and Restore Layouts of DevExpress controls

TreeList Class

TreeList Members

DevExpress.XtraTreeList Namespace