GridOptionsBehavior.AlignGroupSummaryInGroupRowĪnchor the top visible group row to the top of the gridĬustom text can be displayed in group rows via the GridView.CustomDrawGroupRow event. Hide group rows if they contain only a single data row When the View loses focus, the focused and selected rows are painted using the GridViewAppearances.HideSelectionRow property’s settings. When the View has focus, and a group row (as well as a data row) is focused or selected, the row’s appearance is determined by either the GridViewAppearances.FocusedRow or GridViewAppearances.SelectedRow property, respectively. To specify different styles for group rows displayed at different nesting levels, handle the GridView.GroupLevelStyle event. The GridViewAppearances.GroupRow property. The table below lists the main properties that affect element appearance. Group rows can also display group summary values. A group row contains a group expand button that enables end-users to expand and collapse a group row, and thus show or hide its child rows. The sample below restores grouping by the “Order ID” column when end-users clear grouping.Group rows are used to organize data rows into a tree when data grouping is applied. OptionsColumn.AllowGroup - disables the “Ungroup” option in the column context menu.ĬolumnView.StartGrouping, ColumnView.EndGrouping - allow you to re-apply initial column grouping when end-users select “Clear Grouping” in the group panel context menu. OptionsColumn.AllowMove - prevents end-users from dragging a column header, including dragging it away from the group panel. Optionally, a control can be used ( DataGridViewGrouperControl) to provide a user interface to alter the grouping. The component can be added in the designer or in code.
To remove all grouping, right-click the group panel and select “Clear Grouping”. The DataGridViewGrouper is a component that can add grouping functionality to any existing DataGridView. To ungroup data, drag a column header from the group panel to the column header panel, or right-click a column header and select “Ungroup” from the context menu. GridOptionsBehavior.AutoExpandAllGroups - if this setting is enabled, all groups will automatically expand after grouping. GridOptionsView.ShowGroupedColumns - specifies whether or not columns by which data is grouped should still be visible within the View. Hiding this panel does not disable grouping. GridOptionsView.ShowGroupPanel - manages the group panel visibility. OptionsColumn.AllowMove - prevents end-users from dragging a column header, including dragging it inside the group panel. OptionsColumn.AllowGroup - disables grouping by this specific column. GridOptionsCustomization.AllowGroup - disables grouping by Grid Columns.
Both approaches work in Visual Studio and at runtime.īy default, when you group data by columns, these columns automatically hide from the View, and all groups collapse. Another option is to right-click a column header and select “Group By This Column”. To group data by a column, drag a column header into the group panel. The grouping feature combines rows with identical column values into the same data groups.ĭata grouping is enabled in the Data Grid by default.