Skip to main content
A newer version of this page is available. .

PivotGridControl.SaveLayoutToXml(String) Method

Saves the PivotGridControl’s layout to a file in XML format.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v18.2.dll

Declaration

public void SaveLayoutToXml(
    string fileName
)

Parameters

Name Type Description
fileName String

A String value that specifies the target file name.

Remarks

To restore the grid layout previously saved by the SaveLayoutToXml method, use the PivotGridControl.RestoreLayoutFromXml or PivotGridControl.RestoreLayoutFromXmlAsync 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.

Example

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.

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