PivotGridControl.RestoreLayoutFromXml(String) Method

Restores the pivot grid's layout from the specified XML file.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v20.1.dll

Declaration

public void RestoreLayoutFromXml(
    string fileName
)
Public Sub RestoreLayoutFromXml(
    fileName As String
)

Parameters

Name Type Description
fileName String

A String value that specifies the target file name.

Remarks

To save the pivot grid's layout, use the PivotGridControl.SaveLayoutToXml method.

Note that you should specify unique names for all pivot grid fields to correctly save and restore the layout. You can do this using the PivotGridField.Name property.

To learn more, see Save and Restore Layout.

Examples

The following example shows how to save the pivot grid's layout to a file in XML format. To investigate how this works, click the "Save" button, which calls the PivotGridControl.SaveLayoutToXml method. Once saved, the pivot grid's layout can then be restored by clicking the "Load" button, which calls the PivotGridControl.RestoreLayoutFromXml method.

NOTE

The complete sample project How to save and restore the layout to/from XML is available at GitHub.

Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.OleDb
Imports System.Windows
Imports DevExpress.Xpf.PivotGrid
Imports HowToBindToMDB.NwindDataSetTableAdapters

Namespace HowToBindToMDB
    Partial Public Class MainWindow
        Inherits Window
        Private salesPersonDataTable As New NwindDataSet.SalesPersonDataTable()
        Private salesPersonDataAdapter As New SalesPersonTableAdapter()

        Public Sub New()
            InitializeComponent()
            pivotGridControl1.DataSource = salesPersonDataTable
        End Sub

        Private Sub Window_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
            salesPersonDataAdapter.Fill(salesPersonDataTable)
        End Sub

        Private Sub buttonSave_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            pivotGridControl1.SaveLayoutToXml("layout.xml")
        End Sub

        Private Sub buttonLoad_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
            pivotGridControl1.RestoreLayoutFromXml("layout.xml")
        End Sub
    End Class
End Namespace
See Also