Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Data Binding
   [Expand]Views
   [Expand]Data Editing and Validation
   [Collapse]Grouping
     Working with Groups in Code
   [Expand]Sorting
   [Expand]Filter and Search
   [Expand]Summaries
   [Expand]Focus and Selection Handling
    Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
    Split Presentation
    Row Preview Sections
    Scrolling
   [Expand]Batch Modifications
   [Expand]Hit Information
    Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Working with Groups in Code

Expanded Group and Ungroup Data

GridColumn.Group
Groups data against this column. If data is already grouped by other columns, this column will be added to the end of the grouping queue.

GridColumn.UnGroup
Removes data grouping by this column.

GridView.ClearGrouping
Removes all data grouping.

GridColumn.GroupIndex
Accepts non-negative integer values that specify the column order according to which data is grouped. Values must be unique, which means you cannot apply merged column grouping by setting column group indexes.

ColumnView.SortInfo
A collection that stores specific ColumnSortInfo objects on every grid column involved in sorting and grouping. To apply complex grouping in code, modify this collection manually by calling the GridColumnSortInfoCollection.ClearAndAddRange method. The code below applies two grouping layers: merged grouping by "Ship Country", "Ship City" and "Ship Region" columns, followed by tier two grouping by the "Customer ID" column.


ColumnView.StartGrouping, ColumnView.EndGrouping
Non-cancelable events that fire whenever a grouping operation takes place.

Expanded Modify Group Row Content

GridView.GroupFormat
Allows you to modify group row content. Applies to all group rows within a View.

GridView.CustomDrawGroupRow
Allows you to modify specific group row captions.


GridOptionsBehavior.AlignGroupSummaryInGroupRow
Allows you to display group summaries within group rows.

Expanded Custom Grouping

GridColumn.SortMode
Set this property to Custom to implement custom grouping.

GridView.CustomColumnGroup
Fires for all columns with the custom sort mode when grid data is grouped against these columns. Allows you to implement custom grouping algorithms.

ColumnView.CustomColumnDisplayText or GridView.CustomDrawGroupRow
Handle any of these events to modify group row captions accordingly to your custom grouping algorithms. The sample below illustrates how to break order dates into four seasons and group orders by these seasons.

Expanded Locate and Process Group Rows

Row Handles
Row handles are integer values that identify both data (positive values) and group (negative values) rows.

GridView.GetRowLevel
Identifies the nesting level of a row.

GridView.GetChildRowCount
Returns the number of immediate child rows for a group row.

GridView.GetChildRowHandle
Returns the row handle of a group row's child data row. The following example shows how to change the "Price" column value for all the data rows belonging to the focused data group. Prices change when end-users press the "Discount" button.

GridView.GetParentRowHandle
Returns the row handle of a parent row.

ColumnView.GetRow/ColumnView.GetDataRow
Methods that retrieve System.Data.DataRowView or other objects, which represent data source rows.

Expanded Expand and Collapse Rows

GridView.GetRowExpanded
Returns whether or not the row is expanded.

GridView.ExpandGroupRow/GridView.CollapseGroupRow
Call this method to expand or collapse a row.

GridView.SetRowExpanded
Expands or collapses a row itself and (optionally) all of its child rows.

GridView.GroupRowExpanding/GridView.GroupRowCollapsing
Cancelable events that fire when a group is to be expanded or collapsed.

GridView.GroupRowExpanded/GridView.GroupRowCollapsed
These events occur after a row has been expanded or collapsed.

ColumnView.FocusedRowHandle
Scrolls the View to display the required row and selects this row. Expands the row's parent group.

GridView.MakeRowVisible
Scrolls the View to display the required row. If the row belongs to a group, this group expands. The code snippet below displays all rows whose "InStock" column values equal false.

Expanded See Also

How would you rate this topic?​​​​​​​