Back to Devexpress

GridColumn.Group() Method

windowsforms-devexpress-dot-xtragrid-dot-columns-dot-gridcolumn-a864b695.md

latest6.6 KB
Original Source

GridColumn.Group() Method

Groups data by the values of the current column.

Namespace : DevExpress.XtraGrid.Columns

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
public void Group()
vb
Public Sub Group

Remarks

Grid Views support grouping data by an unlimited number of columns. To group data by the values of a given column, call its Group method. Calling this method has no effect if data is already grouped by the values of this column. If several columns are involved in grouping, the current column will reside at the bottom grouping level after calling its Group method.

To ungroup data by the values of a single column, use the column’s GridColumn.UnGroup method. To clear grouping completely, call the View’s GridView.ClearGrouping method.

Please refer to the Grouping and End-User Capabilities: Grouping topics for detailed information on data grouping in the Grid Control.

The following code snippets (auto-collected from DevExpress Examples) contain references to the Group() method.

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.

winforms-pivot-grid-create-the-underlying-data-source-asynchronously/CS/XtraPivotGrid_CreateDrillDownDataSourceAsync/DrillDownForm.cs#L34

csharp
gridView1.Columns["OrderDate"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
gridView1.Columns["Country"].Group();
gridView1.Columns["City"].Group();

winforms-grid-multiple-row-selection-web-style-checkboxes/CS/E1271/Form1.cs#L36

csharp
private void Form1_Load(object sender, EventArgs e) {
    gridView1.Columns["ParentID"].Group();
    gridView1.ExpandAllGroups();

winforms-grid-conditionally-hide-summaries-from-group-rows/CS/ConditionallyHideSumsInGroupRows/Form1.cs#L26

csharp
summaryMax = (GridGroupSummaryItem)gridView1.GroupSummary.Add(SummaryItemType.Max, "Unit Price");
gridView1.Columns["Discontinued"].Group();
gridView1.GroupFormat = "{0}: [#image]{1} "; // summaries are hidden for simpler string composing in CustomDrawGroupRow

winforms-grid-hide-vertical-lines-between-certain-columns/CS/E3647/Form1.cs#L69

csharp
{
    gridView1.Columns["Number"].Group();
    gridView1.ExpandAllGroups();

winforms-pivot-grid-create-the-underlying-data-source-asynchronously/VB/XtraPivotGrid_CreateDrillDownDataSourceAsync/DrillDownForm.vb#L28

vb
gridView1.Columns("OrderDate").DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime
gridView1.Columns("Country").Group()
gridView1.Columns("City").Group()

winforms-grid-multiple-row-selection-web-style-checkboxes/VB/E1271/Form1.vb#L35

vb
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    gridView1.Columns("ParentID").Group()
    gridView1.ExpandAllGroups()

winforms-grid-conditionally-hide-summaries-from-group-rows/VB/ConditionallyHideSumsInGroupRows/Form1.vb#L27

vb
summaryMax = CType(gridView1.GroupSummary.Add(SummaryItemType.Max, "Unit Price"), GridGroupSummaryItem)
gridView1.Columns("Discontinued").Group()
gridView1.GroupFormat = "{0}: [#image]{1} " ' summaries are hidden for simpler string composing in CustomDrawGroupRow

winforms-grid-hide-vertical-lines-between-certain-columns/VB/E3647/Form1.vb#L66

vb
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    gridView1.Columns("Number").Group()
    gridView1.ExpandAllGroups()

See Also

UnGroup()

GroupIndex

ClearGrouping()

Data Grouping

End-User Capabilities: Grouping

GridColumn Class

GridColumn Members

DevExpress.XtraGrid.Columns Namespace