GridColumn.Summary Property
Allows you to add multiple total summaries for a column. These summaries are displayed within the View Footer.
Namespace: DevExpress.XtraGrid.Columns
Assembly: DevExpress.XtraGrid.v24.2.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
Declaration
[XtraSerializableProperty(true, true, true, 1000)]
[XtraSerializablePropertyId(2)]
[DXCategory("Data")]
public GridColumnSummaryItemCollection Summary { get; }
Property Value
Type | Description |
---|---|
GridColumnSummaryItemCollection | A GridColumnSummaryItemCollection object that is a collection of column total summaries. |
Remarks
You can calculate multiple total summaries for a single column via the Summary property. Total summaries, which are calculated against all rows, are displayed in the View Footer. To display the View Footer, use the GridOptionsView.ShowFooter property, accessible via the GridView.OptionsView property.
The Summary object is a collection of summaries. Each summary is a GridColumnSummaryItem object. To add multiple total summaries for a column, you can use the GridColumnSummaryItemCollection.Add method, provided by the Summary object.
You can also add summary items at design time via the grid’s summary collection editor. To open the editor, locate the Summary property in the Properties window and click on the ellipsis button.
An end-user can add multiple summaries for a column at runtime, via the Footer Context Menu. This feature is controlled by the GridOptionsMenu.ShowAddNewSummaryItem property.
If you need to calculate only one summary item for a column, you can use the column’s GridColumn.SummaryItem property instead of adding the summary items to the Summary collection. The first element of Summary collection is synchronized with a column’s GridColumn.SummaryItem property.
Online Video
WinForms Grid: Multiple Summary Values Under the Same Column.
Example
This example demonstrates how to add multiple total summaries for a column at runtime.
using DevExpress.XtraGrid;
//...
gridView1.Columns["UnitsInStock"].Summary.Add(new GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Average, "UnitsInStock", "Avg={0:n2}"));
gridView1.Columns["UnitsInStock"].Summary.Add(new GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Sum, "UnitsInStock", "Sum={0}"));
gridView1.Columns["UnitsInStock"].Summary.Add(new GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Max, "UnitsInStock", "Max={0}"));