Skip to main content

GridColumn.GroupInterval Property

Gets or sets how data rows are grouped by a specific column. The following help section describes the limitations of server mode: Server Mode Limitations and Specifics.

Namespace: DevExpress.XtraGrid.Columns

Assembly: DevExpress.XtraGrid.v24.2.dll

Declaration

[DefaultValue(ColumnGroupInterval.Default)]
[DXCategory("Data")]
[XtraSerializableProperty]
[XtraSerializablePropertyId(2)]
public ColumnGroupInterval GroupInterval { get; set; }

Property Value

Type Default Description
ColumnGroupInterval Default

A ColumnGroupInterval value that determines how data rows are grouped.

Available values:

Name Description
Default

For columns which store date/time values, this option is the same as the ColumnGroupInterval.Date option. For non date/time columns this option is the same as the ColumnGroupInterval.Value option.

Value

Rows are grouped by values of grouping columns. The number of groups matches the number of unique values within the grouping column.

For date/time columns, both the date and time portions are taken into account for value comparison. To specify how date/time values are presented in group rows in WinForms Data Grid, apply formatting to the grouping column (e.g., with the GridColumn.DisplayFormat property).

Date

This option is in effect only for columns that store date/time values.

Rows are grouped by the date part of their values, the time portion is ignored in this grouping mode.

DateMonth

This option is in effect only for columns that store date/time values.

Rows are grouped by the month part of their values.

DateYear

This option is in effect only for columns that store date/time values.

Rows are grouped by the year part of their values.

DateRange

This option is in effect for columns that store date/time values. Rows are combined into the following non-overlapping groups according to their date value as compared with today’s date:

“Beyond Next Month”,

“Next Month”,

“Later this Month”,

“Three Weeks Away”,

“Two Weeks Away”,

“Next Week”,

“Today”,

“Tomorrow”,

“Yesterday”,

“Sunday”,

“Monday”,

“Tuesday”,

“Wednesday”,

“Thursday”,

“Friday”,

“Saturday”,

“Last Week”,

“Two Weeks Ago”,

“Three Weeks Ago”,

“Earlier this Month”,

“Last Month”,

“Older”.

Alphabetical

Rows are grouped by the character that grouping column values start with.

Note

Not supported in server mode for numeric and date/time columns.

DisplayText

Rows are grouped by display values of the grouping column.

In specific instances, column cells can have different edit values, but the same display value. To combine these rows into the same group, use the DisplayText group mode.

Note

Not supported in server mode.

Remarks

Use the GroupInterval property to change how data rows are grouped.

DateTime Values

You can group DateTime values by value, date, month, year, or choose the DateRange value to group dates in predefined categories: “Today”, “Later this Month”, etc.

The following example groups values in the “Birth Date” column by year:

using DevExpress.XtraGrid;
void Form1_Shown(object sender, EventArgs e) {
  gridView1.Columns["BirthDate"].Group();
  gridView1.Columns["BirthDate"].GroupInterval = ColumnGroupInterval.DateYear;
}

The following image shows the result:

DevExpress WinForms Data Grid group DateTime values by year

Numeric Values

You can group numeric values by value or display text (suitable for formatted values).

The following example groups values in the “Salary” column by display text. The column stores numeric values but formats them as currency.

using DevExpress.XtraGrid;
void Form1_Shown(object sender, EventArgs e) {
  gridView1.Columns["Salary"].Group();
  gridView1.Columns["Salary"].GroupInterval = ColumnGroupInterval.DisplayText;
}

The following image shows the result:

DevExpress WinForms Data Grid group numeric values by display text

Custom Group Intervals

Handle the GridView.CustomColumnGroup event to implement a custom grouping logic. See the event’s description for more information.

Read the following help topic for an overview of group modes: Working with Groups in Code.

End User Capabilities

End users can change the group interval for DateTime values in the Group Interval sub-menu of the column header menu.

DevExpress WinForms Data Grid change group interval in context menu

The GridOptionsMenu.ShowDateTimeGroupIntervalItems option controls the visibility of this sub-menu. The default value is true.

Note

The GroupInterval property is not supported in server mode when you bind to data with a WcfLinq.WcfServerModeSource or a WcfLinq.WcfInstantFeedbackSource. For limitations related to other server mode data sources, see the following help topics:

See Also