Back to Devexpress

PivotGridCustomTotalCollection Class

windowsforms-devexpress-dot-xtrapivotgrid-eac0b88a.md

latest5.7 KB
Original Source

PivotGridCustomTotalCollection Class

Represents a collection of custom totals for a field.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

csharp
public class PivotGridCustomTotalCollection :
    PivotGridCustomTotalCollectionBase
vb
Public Class PivotGridCustomTotalCollection
    Inherits PivotGridCustomTotalCollectionBase

The following members return PivotGridCustomTotalCollection objects:

Remarks

A field’s PivotGridField.CustomTotals property of the PivotGridCustomTotalCollection class represents a collection of custom totals.

The PivotGrid control allows you to display automatic or custom totals for outer column fields and row fields. By default, the field’s PivotGridFieldBase.TotalsVisibility property is set to PivotTotalsVisibility.AutomaticTotals, so automatic totals are displayed. To display custom totals, do the following:

When a sequence of operations is performed each of which affects the control’s appearance, the PivotGrid control updates itself after each such operation. To prevent excessive updates you should enclose the code within calls to the PivotGridControl.BeginUpdate and PivotGridControl.EndUpdate methods. For instance, when setting custom totals for a field via code you can enclose the code within the BeginUpdate and EndUpdate method calls. In this case, the control will be updated only once - by the EndUpdate method.

Example

In the following example, four custom totals are added for a ‘Category Name’ row field. They will calculate the total Average, Sum, Min and Max values against the currently displayed data field.

The result is shown below.

csharp
using DevExpress.Data.PivotGrid;
using DevExpress.XtraPivotGrid;

// Get a reference to the CategoryName field.
PivotGridField field = pivotGridControl1.Fields["CategoryName"];
pivotGridControl1.BeginUpdate();
try {
   // Clear the custom total collection.
   field.CustomTotals.Clear();
   // Add four items to the custom total collection to calculate the Average, 
   // Sum, Max and Min summaries.
   field.CustomTotals.Add(PivotSummaryType.Average);
   field.CustomTotals.Add(PivotSummaryType.Sum);
   field.CustomTotals.Add(PivotSummaryType.Max);
   field.CustomTotals.Add(PivotSummaryType.Min);
   // Make the custom totals visible for this field.
   field.TotalsVisibility = PivotTotalsVisibility.CustomTotals; 
}
finally {
   pivotGridControl1.EndUpdate();
}
vb
Imports DevExpress.Data.PivotGrid
Imports DevExpress.XtraPivotGrid

' Get a reference to the CategoryName field.
Dim field As PivotGridField = pivotGridControl1.Fields("CategoryName")
pivotGridControl1.BeginUpdate()
Try
   ' Clear the custom total collection.
   field.CustomTotals.Clear()
   ' Add four items to the custom total collection to calculate the Average, 
   ' Sum, Max and Min summaries.
   field.CustomTotals.Add(PivotSummaryType.Average)
   field.CustomTotals.Add(PivotSummaryType.Sum)
   field.CustomTotals.Add(PivotSummaryType.Max)
   field.CustomTotals.Add(PivotSummaryType.Min)
   ' Make the custom totals visible for this field.
   field.TotalsVisibility = PivotTotalsVisibility.CustomTotals
Finally
   pivotGridControl1.EndUpdate()
End Try

Inheritance

Object CollectionBase PivotGridCustomTotalCollectionBase PivotGridCustomTotalCollection

See Also

PivotGridCustomTotalCollection Members

TotalsVisibility

CustomTotals

DevExpress.XtraPivotGrid Namespace