Back to Devexpress

GridSummaryItem.Mode Property

windowsforms-devexpress-dot-xtragrid-dot-gridsummaryitem-dcdaca4b.md

latest5.8 KB
Original Source

GridSummaryItem.Mode Property

Gets or sets whether to calculate the current summary against all rows or the selection. Use this property when you enable multiple row selection (see ColumnView.OptionsSelection.MultiSelect). This property is not supported in server mode.

Namespace : DevExpress.XtraGrid

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue(SummaryMode.AllRows)]
[DXCategory("Behavior")]
[XtraSerializableProperty(2)]
public virtual SummaryMode Mode { get; set; }
vb
<DefaultValue(SummaryMode.AllRows)>
<XtraSerializableProperty(2)>
<DXCategory("Behavior")>
Public Overridable Property Mode As SummaryMode

Property Value

TypeDefaultDescription
SummaryModeAllRows

A value that specifies whether the current summary is calculated against all rows or the selection.

|

Available values:

NameDescription
AllRows

Calculate a summary against all rows.

| | Selection |

Calculate a summary against the selection.

| | Mixed |

Mixed mode. If a single row is selected, calculate a summary against all rows. If 2 or more rows are selected, calculate the summary against the selection.

| | ListSourceRows | |

Remarks

In multiple row selection mode (see ColumnView.OptionsSelection.MultiSelect), summaries are initially calculated against all rows. To calculate summaries against the selected rows, set the GridSummaryItem.Mode property to SummaryMode.Selection or SummaryMode.Mixed.

Note

Controls bound to large data sources in server mode do not support the SummaryMode.Selection and SummaryMode.Mixed options.

csharp
using DevExpress.Data;
using DevExpress.XtraGrid;

gridView1.OptionsView.ShowFooter = true;
gridView1.OptionsSelection.MultiSelect = true;
colOrderID.Summary.AddRange(new GridSummaryItem[] {new GridColumnSummaryItem(SummaryItemType.Count, SummaryMode.Selection, "ProductName", "COUNT={0}")});
vb
Imports DevExpress.Data
Imports DevExpress.XtraGrid

GridView1.OptionsView.ShowFooter = True
GridView1.OptionsSelection.MultiSelect = True
colOrderID.Summary.AddRange(New GridSummaryItem() {New GridColumnSummaryItem(SummaryItemType.Count, SummaryMode.Selection, "ProductName", "COUNT={0}")})

Selection and Mixed modes produce different results when you select a single data row. The summary is calculated against the selected row in Selection mode, and against all rows in Mixed mode.

The Data Grid control displays a special icon to indicate summaries calculated against a subset of rows:

The Data Grid does not use additional icons for summaries calculated against all rows.

Note

You can set the GridView.OptionsSelection.MultiSelectMode property to CellSelect to allow a user to select multiple cells. The Data Grid calculates summaries against the rows that contain the selected cells, but not against individual cells.

Data Grouping

When a user selects one or more group rows, summaries (in Selection or Mixed mode) are calculated across all children of the selected groups.

If you select a data row(s) within a group, the summary ignores non-selected rows in this group.

Change Summary Mode at Runtime

Enable the GridOptionsMenu.ShowSummaryItemMode option to allow users to specify summary mode at runtime via a context menu.

See Also

ShowSummaryItemMode

MultiSelect

ShowFooter

GridSummaryItem Class

GridSummaryItem Members

DevExpress.XtraGrid Namespace