Back to Devexpress

PivotGridField.CustomTotals Property

windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridfield-b2711d87.md

latest5.1 KB
Original Source

PivotGridField.CustomTotals Property

Gets the current field’s custom total collection.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

csharp
[Browsable(true)]
[XtraSerializableProperty(XtraSerializationVisibility.Collection, true, true, true, 0, XtraSerializationFlags.DefaultValue)]
public PivotGridCustomTotalCollection CustomTotals { get; }
vb
<Browsable(True)>
<XtraSerializableProperty(XtraSerializationVisibility.Collection, True, True, True, 0, XtraSerializationFlags.DefaultValue)>
Public ReadOnly Property CustomTotals As PivotGridCustomTotalCollection

Property Value

TypeDescription
PivotGridCustomTotalCollection

A PivotGridCustomTotalCollection object which represent the custom totals’ collection.

|

Remarks

The PivotGrid control lets you calculate automatic or custom totals against data fields. These totals are displayed as an additional column(s) for each value in an outer column field and as an additional row for each value in an outer row field.

The CustomTotals collection contains PivotGridCustomTotal objects which represent custom totals for the current field. They are displayed when the field is positioned within the Column Header Area or Row Header Area and only if its PivotGridFieldBase.TotalsVisibility property is set to PivotTotalsVisibility.CustomTotals.

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

See Also

TotalsVisibility

ShowCustomTotals

PivotGridField Class

PivotGridField Members

DevExpress.XtraPivotGrid Namespace