windowsforms-devexpress-dot-xtragrid-dot-gridsummaryitem.md
Gets or sets the aggregation function type.
Namespace : DevExpress.XtraGrid
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[DefaultValue(SummaryItemType.None)]
[DXCategory("Behavior")]
[XtraSerializableProperty(1)]
public SummaryItemType SummaryType { get; set; }
<DefaultValue(SummaryItemType.None)>
<XtraSerializableProperty(1)>
<DXCategory("Behavior")>
Public Property SummaryType As SummaryItemType
| Type | Default | Description |
|---|---|---|
| SummaryItemType | None |
A SummaryItemType enumeration value specifying the summary type.
|
Available values:
| Name | Description |
|---|---|
| Sum |
The sum of all values in a column.
| | Min |
The minimum value in a column.
| | Max |
The maximum value in a column.
| | Count |
The record count.
| | Average |
The average value of a column.
| | Custom |
Specifies whether calculations should be performed manually using a specially designed event.
| | None |
Disables summary value calculation.
|
Use the SummaryType property to specify the type of aggregate function used to calculate the summary value. The following predefined aggregate functions are available:
using DevExpress.XtraGrid;
gridView1.OptionsView.ShowFooter = true;
GridColumnSummaryItem siTotal = new GridColumnSummaryItem();
siTotal.SummaryType = SummaryItemType.Count;
siTotal.DisplayFormat = "{0} records";
colOrderID.Summary.Add(siTotal);
GridColumnSummaryItem siAverage = new GridColumnSummaryItem();
siAverage.SummaryType = SummaryItemType.Average;
siAverage.FieldName = "Freight";
siAverage.DisplayFormat = "Average: {0:#.#}";
gridView1.Columns["Freight"].Summary.Add(siAverage);
Imports DevExpress.XtraGrid
gridView1.OptionsView.ShowFooter = True
Dim siTotal As New GridColumnSummaryItem()
siTotal.SummaryType = SummaryItemType.Count
siTotal.DisplayFormat = "{0} records"
colOrderID.Summary.Add(siTotal)
Dim siAverage As New GridColumnSummaryItem()
siAverage.SummaryType = SummaryItemType.Average
siAverage.FieldName = "Freight"
siAverage.DisplayFormat = "Average: {0:#.#}"
gridView1.Columns("Freight").Summary.Add(siAverage)
These five aggregate functions do not limit the types of summaries you can use. You can implement your own aggregate functions. For this purpose, set the SummaryType property to the SummaryItemType.Custom value and write a GridView.CustomSummaryCalculate event handler.
The following code snippets (auto-collected from DevExpress Examples) contain references to the SummaryType property.
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.
if (modelColumn != null) {
modelColumn.GroupFooterSummaryType = gridView.GroupSummary[i].SummaryType;
}
winforms-grid-customize-footer-menu-calculate-custom-totals/CS/Form1.cs#L52
DevExpress.XtraGrid.Menu.GridViewFooterMenu footerMenu = e.Menu as DevExpress.XtraGrid.Menu.GridViewFooterMenu;
bool check = e.HitInfo.Column.SummaryItem.SummaryType == DevExpress.Data.SummaryItemType.Custom && Equals("Count", e.HitInfo.Column.SummaryItem.Tag);
DevExpress.Utils.Menu.DXMenuItem menuItem = new DevExpress.Utils.Menu.DXMenuCheckItem("Active Count", check, null, new EventHandler(MyMenuItem));
{
gridView1.Columns["OrderDate"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Count;
gridView1.Columns["OrderDate"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
winforms-grid-print-custom-draw-content/CS/MyXtraGrid/MyGridView/MyGridViewPrintInfo.cs#L34
{
if (colInfo.Column.SummaryItem.SummaryType == SummaryItemType.None) continue;
Rectangle r = Rectangle.Empty;
winforms-grid-customize-footer-menu-calculate-custom-totals/VB/Form1.vb#L45
Dim footerMenu As DevExpress.XtraGrid.Menu.GridViewFooterMenu = TryCast(e.Menu, DevExpress.XtraGrid.Menu.GridViewFooterMenu)
Dim check As Boolean = e.HitInfo.Column.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Custom AndAlso Equals("Count", e.HitInfo.Column.SummaryItem.Tag)
Dim menuItem As DevExpress.Utils.Menu.DXMenuItem = New DevExpress.Utils.Menu.DXMenuCheckItem("Active Count", check, Nothing, New EventHandler(AddressOf MyMenuItem))
Friend Sub ArrangeLayout()
gridView1.Columns("OrderDate").SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Count
gridView1.Columns("OrderDate").DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime
winforms-grid-print-custom-draw-content/VB/MyXtraGrid/MyGridView/MyGridViewPrintInfo.vb#L32
For Each colInfo As PrintColumnInfo In Columns
If colInfo.Column.SummaryItem.SummaryType = SummaryItemType.None Then
Continue For
See Also