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.v18.2.dll
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.
gridView1.Columns["UnitsInStock"].Summary.Add(DevExpress.Data.SummaryItemType.Average, "UnitsInStock", "Avg={0:n2}");
gridView1.Columns["UnitsInStock"].Summary.Add(DevExpress.Data.SummaryItemType.Sum, "UnitsInStock", "Sum={0}");
GridColumnSummaryItem item = new GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Max, "UnitsInStock", "Max={0}");
gridView1.Columns["UnitsInStock"].Summary.Add(item);
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Summary 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.