Back to Devexpress

PivotGridControl.SaveLayoutToXml(String) Method

windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridcontrol-dot-savelayouttoxml-x28-system-dot-string-x29.md

latest4.5 KB
Original Source

PivotGridControl.SaveLayoutToXml(String) Method

SECURITY-RELATED CONSIDERATIONS

Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.

Saves a Pivot Grid Control’s layout to an XML file.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

csharp
public void SaveLayoutToXml(
    string xmlFile
)
vb
Public Sub SaveLayoutToXml(
    xmlFile As String
)

Parameters

NameTypeDescription
xmlFileString

A string value specifying the path to the file where a Pivot Grid Control’s layout should be stored. If an empty string is specified, an exception is raised.

|

Remarks

Use the SaveLayoutToXml method to save a Pivot Grid Control’s layout to a specific XML file at runtime. The saved settings can then be restored using the PivotGridControl.RestoreLayoutFromXml 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 PivotGridFieldBase.Name property.

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

Note

The expansion states of field values are not saved by the SaveLayoutToXml 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 code below demonstrates how the Pivot Grid Control’s layout can be saved to and then restored from an XML file.

csharp
string fileName = "c:\\XtraPivotGrid_Layout.xml";
// Saves layout to an XML file.
pivotGridControl1.SaveLayoutToXml(fileName);

// ...
// Restores the previously saved layout.
pivotGridControl1.RestoreLayoutFromXml(fileName);
vb
Dim fileName As String = "c:\XtraPivotGrid_Layout.xml"
' Saves layout to an XML file.
PivotGridControl1.SaveLayoutToXml(fileName)

' ...
' Restores the previously saved layout.
PivotGridControl1.RestoreLayoutFromXml(fileName)

See Also

RestoreLayoutFromXml

SaveLayoutToRegistry

SaveLayoutToStream

SaveCollapsedStateToFile(String)

SaveCollapsedStateToStream(Stream)

LoadCollapsedStateFromFile(String)

LoadCollapsedStateFromStream(Stream)

LayoutUpgrade

OptionsLayout

Save and Restore Layouts of DevExpress controls

PivotGridControl Class

PivotGridControl Members

DevExpress.XtraPivotGrid Namespace