Back to Devexpress

PivotGridControl.SaveLayoutToStream(Stream) Method

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

latest5.4 KB
Original Source

PivotGridControl.SaveLayoutToStream(Stream) Method

Saves a Pivot Grid Control’s layout to the specified stream.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

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

Parameters

NameTypeDescription
streamStream

A Stream descendant to which a Pivot Grid Control’s layout is written.

|

Remarks

Use the SaveLayoutToStream method to write a Pivot Grid Control’s layout to a stream. The layout can then be read using the PivotGridControl.RestoreLayoutFromStream method.

The PivotGridControl.OptionsLayout property controls which settings should be saved to the stream.

Note

The expansion states of field values are not saved by the SaveLayoutToStream method.

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 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 SaveLayoutToStream(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#L44

csharp
private void simpleButton1_Click(object sender, EventArgs e){
    pivotGridControlOld.SaveLayoutToStream(layoutStream);
}

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

vb
Private Sub simpleButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
    pivotGridControlOld.SaveLayoutToStream(layoutStream)
End Sub

See Also

RestoreLayoutFromStream

SaveLayoutToRegistry

SaveLayoutToXml

SaveCollapsedStateToFile(String)

SaveCollapsedStateToStream(Stream)

LoadCollapsedStateFromFile(String)

LoadCollapsedStateFromStream(Stream)

LayoutUpgrade

OptionsLayout

Save and Restore Layouts of DevExpress controls

PivotGridControl Class

PivotGridControl Members

DevExpress.XtraPivotGrid Namespace