Back to Devexpress

PivotGridControl.CustomSummary Event

windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridcontrol-036d9035.md

latest9.4 KB
Original Source

PivotGridControl.CustomSummary Event

Allows you to calculate a custom summary.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

csharp
public event PivotGridCustomSummaryEventHandler CustomSummary
vb
Public Event CustomSummary As PivotGridCustomSummaryEventHandler

Event Data

The CustomSummary event's data class is PivotGridCustomSummaryEventArgs. The following properties provide information specific to this event:

PropertyDescription
ColumnFieldGets the column field that corresponds to the current cell. Inherited from PivotGridCustomSummaryEventArgsBase<T>.
ColumnFieldValueGets the value of the column field that corresponds to the current cell. Inherited from PivotGridCustomSummaryEventArgsBase<T>.
CustomValueGets or sets a custom summary value. Inherited from PivotGridCustomSummaryEventArgsBase<T>.
DataFieldGets the data field against which the summary is calculated. Inherited from PivotGridCustomSummaryEventArgsBase<T>.
FieldNameGets the name of the data field against which the summary is calculated. Inherited from PivotGridCustomSummaryEventArgsBase<T>.
RowFieldGets the row field that corresponds to the current cell. Inherited from PivotGridCustomSummaryEventArgsBase<T>.
RowFieldValueGets the value of the row field that corresponds to the current cell. Inherited from PivotGridCustomSummaryEventArgsBase<T>.
SummaryValueGets an object that contains the values of the predefined summaries which are calculated for the current cell. Inherited from PivotGridCustomSummaryEventArgsBase<T>.

The event data class exposes the following methods:

MethodDescription
CreateDrillDownDataSource()Returns data records associated with the current cell. Inherited from PivotGridCustomSummaryEventArgsBase<T>.

Remarks

Note

This member is no longer supported in Optimized and Server modes. Use ExpressionDataBinding instead.

The Pivot Grid Control calculates summaries against data fields. A field’s PivotGridFieldBase.SummaryType property specifies the type of summary function. The control automatically calculates built-in summaries (see the PivotSummaryType topic for a list of the available functions. You can handle the the CustomSummary event and calculate the custom summaries manually.

To calculate a custom summary for a specific data field, set its PivotGridFieldBase.SummaryType property to PivotSummaryType.Custom. In this case, the CustomSummary event will fire for each cell that corresponds to this data field.

For instance, this event enables a custom summary to be calculated against multiple fields, particular records, etc. Use the PivotGridCustomSummaryEventArgsBase<T>.CreateDrillDownDataSource method to get a list of the records that correspond to the current cell. This list can then be traversed to calculate a summary in a custom manner. The custom summary value should be assigned to the PivotGridCustomSummaryEventArgsBase<T>.CustomValue parameter.

For each cell, the Pivot Grid Control calculates all the predefined summaries (AVERAGE, MIN, MAX, SUM, etc). The calculated values can be accessed using the PivotGridCustomSummaryEventArgsBase<T>.SummaryValue property. You can use them in custom summary calculations.

The following code snippets (auto-collected from DevExpress Examples) contain references to the CustomSummary event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-pivotgrid--display-the-difference-of-income-and-outlay-in-totals/CS/PivotGridCustomSummaryExample/Form1.cs#L48

csharp
pivotGridControl1.Fields["Value"].SummaryType = DevExpress.Data.PivotGrid.PivotSummaryType.Custom;
    pivotGridControl1.CustomSummary += pivotGridControl1_CustomSummary;
}

winforms-pivot-grid-provide-custom-summary-values-for-cells/CS/WinPivotCustomSummaryCellType/Form1.cs#L10

csharp
pivotGridControl1.CustomSummary += new PivotGridCustomSummaryEventHandler(pivotGridControl1_CustomSummary);
customerReportsTableAdapter1.Fill(nwindDataSet1.CustomerReports);

winforms-pivotgrid--display-the-difference-of-income-and-outlay-in-totals/VB/PivotGridCustomSummaryExample/Form1.vb#L39

vb
pivotGridControl1.Fields("Value").SummaryType = DevExpress.Data.PivotGrid.PivotSummaryType.Custom
    AddHandler pivotGridControl1.CustomSummary, AddressOf pivotGridControl1_CustomSummary
End Sub

See Also

SummaryType

How to provide custom summary values for Total, Grand Total and ordinary cells

PivotGridControl Class

PivotGridControl Members

DevExpress.XtraPivotGrid Namespace