GridGroupSummaryItem Class

Represents an individual group summary item.

Namespace: DevExpress.XtraGrid

Assembly: DevExpress.XtraGrid.v20.1.dll

Declaration

public class GridGroupSummaryItem :
    GridSummaryItem
Public Class GridGroupSummaryItem
    Inherits GridSummaryItem

Remarks

Grid Views provide the GridView.GroupSummary property which is a collection of group summary items. Each group summary item is represented by a GridGroupSummaryItem object. Such objects provide settings that specify the aggregation function type, the field whose values are used to calculate the function value and the summary value formatting. Aggregate function values are calculated for each group of rows. Formatted results are displayed either within group rows or group footers under the specified column. Please refer to the Summaries topic for additional information.

The GridGroupSummaryItem class inherits members affecting summary item customization from the GridSummaryItem class that is used to represent total summary items. The GridGroupSummaryItem.ShowInGroupColumnFooter property introduced specifies the summary value position. If set to a column, summary values will be displayed within row footer cells under the specified column. If set to null (Nothing in Visual Basic), summary values will be displayed within group rows.

GridGroupSummaryItem_class.gif

To create group summaries at runtime, you need to create GridGroupSummaryItem objects, customize them as needed and add them to the GridView.GroupSummary collection.

Examples

The following example shows how to create two group summary items. The first summary item will represent the number of records within groups, and will be displayed in group rows. The second item will calculate the sum of values against the UnitPrice field, and will be displayed under the Unit Price column within group footers. The result of the code execution is presented below:

Summary-GroupCodeResult

using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;

// Make the group footers always visible.
gridView1.OptionsView.GroupFooterShowMode = GroupFooterShowMode.VisibleAlways;
// Create and setup the first summary item.
GridGroupSummaryItem item = new GridGroupSummaryItem();
item.FieldName = "ProductName";
item.SummaryType = DevExpress.Data.SummaryItemType.Count;         
gridView1.GroupSummary.Add(item);
// Create and setup the second summary item.
GridGroupSummaryItem item1 = new GridGroupSummaryItem();
item1.FieldName = "UnitPrice";
item1.SummaryType = DevExpress.Data.SummaryItemType.Sum;
item1.DisplayFormat = "Total {0:c2}";
item1.ShowInGroupColumnFooter = gridView1.Columns["UnitPrice"];
gridView1.GroupSummary.Add(item1);

Inheritance

Object
GridSummaryItem
GridGroupSummaryItem
See Also