Back to Devexpress

PivotGridControl.RestoreLayoutFromJson(Stream) Method

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

latest3.3 KB
Original Source

PivotGridControl.RestoreLayoutFromJson(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 Pivot Grid’s layout settings specified by the OptionsLayout property from a file in JSON format.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

csharp
public void RestoreLayoutFromJson(
    Stream utf8jsonStream
)
vb
Public Sub RestoreLayoutFromJson(
    utf8jsonStream As Stream
)

Parameters

NameTypeDescription
utf8jsonStreamStream

The layout in UTF-8 encoded JSON format.

|

Remarks

Use the SaveLayoutToJson method to save the layout to a file in JSON format.

csharp
string filePath = "pivotgrid-layout.json";
void Form1_Load(object sender, EventArgs e) {
    if (File.Exists(filePath)) {
        using (var jsonStream = File.OpenRead(filePath))
            pivotGrid1.RestoreLayoutFromJson(jsonStream);
    }
}

void Form1_FormClosing(object sender, FormClosingEventArgs e) {
    using (var jsonStream = File.OpenWrite(filePath))
        pivotGrid1.SaveLayoutToJson(jsonStream);
}
vb
Private filePath As String = "pivotgrid-layout.json"
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    If File.Exists(filePath) Then
        Using jsonStream = File.OpenRead(filePath)
            pivotGrid1.RestoreLayoutFromJson(jsonStream)
        End Using
    End If
End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)
    Using jsonStream = File.OpenWrite(filePath)
        pivotGrid1.SaveLayoutToJson(jsonStream)
    End Using
End Sub

Tip

Use the Persistence Behavior or Workspace Manager component to save and restore layouts for all DevExpress UI controls simultaneously.

See Also

SaveLayoutToJson

Save and Restore Layouts of DevExpress Controls

PivotGridControl Class

PivotGridControl Members

DevExpress.XtraPivotGrid Namespace