Back to Devexpress

PivotGridControl.RestoreLayoutFromStream(Stream) Method

windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridcontrol-dot-restorelayoutfromstream-x28-system-dot-io-dot-stream-x29.md

latest5.6 KB
Original Source

PivotGridControl.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 a Pivot Grid Control’s layout from the specified stream.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

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

Parameters

NameTypeDescription
streamStream

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

|

Remarks

Use the RestoreLayoutFromStream method to load the Pivot Grid Control’s layout from the stream to which the layout was saved via the PivotGridControl.SaveLayoutToStream method.

The PivotGridControl.OptionsLayout property controls which settings should be restored from the stream.

Note

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

Example

The following sample code saves a Pivot Grid Control’s layout to a memory stream and then restores it.

csharp
System.IO.Stream stream;
stream = new System.IO.MemoryStream();
pivotGridControl1.SaveLayoutToStream(stream);
stream.Seek(0, System.IO.SeekOrigin.Begin);

// ...
pivotGridControl1.RestoreLayoutFromStream(stream);
stream.Seek(0, System.IO.SeekOrigin.Begin);
vb
Dim stream As System.IO.Stream
stream = New System.IO.MemoryStream()
PivotGridControl1.SaveLayoutToStream(stream)
stream.Seek(0, System.IO.SeekOrigin.Begin)

' ...
PivotGridControl1.RestoreLayoutFromStream(stream)
stream.Seek(0, System.IO.SeekOrigin.Begin)

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the RestoreLayoutFromStream(Stream) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

pivot-grid-for-winforms-layout-upgrade/CS/WinPivotUpgradeLayout/Form1.cs#L49

csharp
layoutStream.Seek(0, SeekOrigin.Begin);
    pivotGridControlNew.RestoreLayoutFromStream(layoutStream);
}

pivot-grid-for-winforms-layout-upgrade/VB/WinPivotUpgradeLayout/Form1.vb#L52

vb
layoutStream.Seek(0, SeekOrigin.Begin)
    pivotGridControlNew.RestoreLayoutFromStream(layoutStream)
End If

See Also

SaveLayoutToStream

RestoreLayoutFromRegistry

RestoreLayoutFromXml

SaveCollapsedStateToFile(String)

SaveCollapsedStateToStream(Stream)

LoadCollapsedStateFromFile(String)

LoadCollapsedStateFromStream(Stream)

LayoutUpgrade

OptionsLayout

Save and Restore Layouts of DevExpress controls

PivotGridControl Class

PivotGridControl Members

DevExpress.XtraPivotGrid Namespace