Tutorial: Total Summaries
- 3 minutes to read
DevExpress Data Grid allows you to display total values — the number of records or the maximum and minimum values in a column. This tutorial describes how to the following:
- Allow users to add or remove totals using built-in footer menus.
- Prevent users from modifying totals.
- Specify grid totals at design time or in code.
Starting Point
Start with a GridControl that includes numeric data.

Display the View Footer
To enable total summary display and end-user interaction, show the View Footer:
- In the Properties window, expand the View’s GridView.OptionsView property.
Activate the GridOptionsView.ShowFooter option.

End-User Capabilities
When the View’s footer is visible, a user can do the following:
Right-click the footer under a column to add a summary item:

Right-click an existing total summary cell to add more summary items:

Right-click a summary to change the summary function:

Right-click a summary item and select None in the context menu to hide the summary:

Hide all summaries under a column:

Restrict End-User Capabilities
To prevent users from changing predefined summaries, disable the footer context menu:
In the Properties window, expand the GridView.OptionsMenu property.
Disable the GridOptionsMenu.EnableFooterMenu option.

Create Summaries at Design Time
Use one of the following ways:
GridColumn.SummaryItem Property (Single Summary)
- In the Properties window, expand a column’s GridColumn.SummaryItem property.
- Set the GridSummaryItem.SummaryType property to the desired aggregate function.
Specify the GridSummaryItem.DisplayFormat property to format the summary value. For example:

Tip
You can calculate a summary value based on values from another column. To do so, set the GridSummaryItem.FieldName property to the field name of the column you want to use for summary calculation.
Collection Editor (Multiple Summaries)
In the Properties window, click the ellipsis button next to the GridColumn.Summary property:

In the opened Collection Editor, specify
SummaryTypeandDisplayFormatproperties for the existing entry. Click Add to add new summary items. When the collection is ready, click OK to save changes.
Create Summaries in Code
Make sure you create summaries after the data source is assigned and the grid view is initialized (for example, on the Form.Load event).
Create a GridColumnSummaryItem object and add it to the GridColumn.Summary collection of the required column:
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.Data;
private void Form1_Load(object? sender, EventArgs e) {
gridView.OptionsView.ShowFooter = true;
GridColumnSummaryItem summary1 = new GridColumnSummaryItem(SummaryItemType.Max, "Quantity", "MAX Count={0}");
gridView.Columns["Quantity"].Summary.Add(summary1);
// You can also use the Summary collection's Add method directly
// gridView.Columns["Quantity"].Summary.Add(SummaryItemType.Max, "Quantity", "MAX Count={0}");
}
The following image shows the result:
