Log In
[Expand]General Information
[Collapse]WinForms Controls
 [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]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
     Summaries Overview
     Tutorial: Custom Summary Functions
     Tutorial: Format Summary Text
     Tutorial: Group Summaries
     Tutorial: Obtain Summary Values
     Tutorial: Sort Group Rows by Summary Values
     Tutorial: Total Summaries
     Total Summary
     Group Summary
     Custom Aggregate Functions
     Format Summary Values
     Obtain Summary Values
     Sorting Group Rows by Summary Values
     Controlling Visibility of Group Summaries for Individual Group Rows
   [Expand]Data Editing
   [Expand]Filtering and Locating Rows
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [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]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Report Server
[Expand]eXpressApp Framework
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Sorting Group Rows by Summary Values

Expanded Online Video

Learn how to use grid built-in UI allowing you to sort group rows by summary values, disable this UI and sort group rows in code.

More Video

WinForms Grid: Sort Group Rows by Summary Value

Expanded Sorting Group Rows by Summary Values

When you group data by a single column, records with identical column values are arranged into corresponding data groups. Each data group is identified by a group row. Group rows are used to organize data rows into a tree when data grouping is applied. By default, each group row displays a text that identifies a column's caption, grouping value and group summary text, if any. By default, records are sorted against grouping columns. If you group data against a non-sorted column, the grid control will automatically apply sorting in ascending order to the column, as shown in the image below.


Grid Control does, however, allow group rows to be sorted by summary values.

Group rows are sorted by summary values based upon the information provided by the GroupSummarySortInfo objects. The properties introduced by these objects represent the nesting level of the group rows that are to be sorted by summary values, and the sort order and summary item used to calculate summary values for groups of rows. These properties are read-only and initialized by the constructor.

To sort group rows by summary values, you should create a new GroupSummarySortInfo object and add it to the View's GridView.GroupSummarySortInfo collection using the GroupSummarySortInfoCollection.Add method. Once the GroupSummarySortInfo object has been added to a collection group, rows are automatically sorted by their summary values.

The following example shows how to sort group rows that reside at the first grouping level by summary values. The group summaries are calculated by the Freight column's values.

The image below shows the result:

To cancel the sorting of group rows by summary values, remove the corresponding GroupSummarySortInfo object from the collection. Note that these objects are automatically removed from the collection after the sort order of the corresponding group columns has been changed.

Expanded Sorting Group Rows by an End-User

If group summaries are created and the GridOptionsMenu.ShowGroupSortSummaryItems option is enabled, an end-user can sort group rows by the group summary values via a context menu. This is accomplished by right-clicking a grouping column's header, and then selecting a corresponding command from the context menu.

Expanded See Also

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