How to: Sort Data by a Data Field

This example demonstrates how to sort the values of a 'Sales Person' column field by summary values calculated against an 'Order Amount' data field. To do this, the PivotGridFieldSortBySummaryInfo.Field property of the 'Sales Person' field is set to reference the 'Order Amount' field. As a result, the values will be arranged in the order specified by the summary values.

The following images show the PivotGridControl before and after the field values are sorted by the summary values.

Before:

PivotGridField.SortBySummary_None

After:

PivotGridField.SortBySummary_Sum

pivotGridControl1.Fields["Sales Person"].SortBySummaryInfo.Field = 
  pivotGridControl1.Fields["Order Amount"];