The example shows how to manage Pivot Grid layout on restore.
The example contains two Pivot Grid controls with the following fields:
The SaveLayout button uses the PivotGridControl.SaveLayoutToStream method to save the pivotGridControlOld
layout to memory streams.
The RestoreLayout button uses the PivotGridControl.RestoreLayoutFromStream method to restore the saved layout to pivotGridControlNew
.
The following options allows you to combine fields from different Pivot Grid controls on restore:
-
PivotGridOptionsLayout.Columns.AddNewColumns that is set to true, keeps the field in the
pivotGridControlNew
control when you restore layout. -
PivotGridOptionsLayout.Columns.RemoveOldColumns that is set to false, adds fields from
pivotGridControlOld
topivotGridControlNew
. -
PivotGridOptionsLayout.AddNewGroups that is set to
true
, keeps the "Year-Quarter" group of thepivotGridControlNew
when you restore layout. -
PivotGridControl.LayoutUpgrade event adds the "Quantity" field to
pivotGridControlNew
's data area when you restore layout.
The following image shows the resulting combination when you save the pivotGridControlOld
layout and restore it to pivotGridControlNew
: