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

Obtain Summary Values

The grid control provides various methods to obtain the values of the Total and Group summaries. This topic describes how to use such methods to access summary values. Basic information about summaries is provided in the Summaries Overview topic.

Expanded Online Video

Learn how to obtain group and total summary values, and use them in calculations and to customize grid Views.

Expanded Obtaining Total Summary Values

As described in the Total Summary topic, such values are calculated for all the records within a View and displayed within the View's footer under a particular column. The column's GridColumn.SummaryItem property stores the GridSummaryItem class object, which specifies the total summary. You can get the summary value via the GridSummaryItem.SummaryValue property. The GridColumn.SummaryText property gets the string representation of the summary value. The summary text, displayed within the Footer Cell can be obtained via the GridSummaryItem.GetDisplayText method.

Expanded Obtaining Group Summary Values

A group summary is specified by the GridView.GroupSummary property, which represents a collection of summary items. Each item can be displayed within its group row or a particular column within the group footer.

The following methods can be used to obtain group summaries displayed within group rows and Group Footer.

  • GridView.GetGroupSummaryValues

    For each group several summaries can be calculated. This method returns the hashtable that contains the values of all the summaries calculated for a specific data group. The key values of this hashtable are summary items (GridGroupSummaryItem objects). Values are the summary values. Thus, you can use index notation to access a particular summary item's value. The desired summary item should be specified as the index parameter. The required data group is identified by the handle of the group row.

  • GridView.GetGroupSummaryValue

    This method returns the value of a specific group summary identified by a summary item.

  • GridView.GetRowSummaryItem

    This method can only be used to get the values of summaries that are displayed within group footers. It returns the dictionary entry that represents the summary item and its value. The entry's key is a GridGroupSummaryItem object that represents a summary item. The value is an object holding the value of the calculated summary.

  • GridView.GetGroupSummaryText

    Gets the summary text displayed within the group row.

  • GridView.GetGroupSummaryDisplayText

    Gets the text representation of a specific group summary's value.

  • GridView.GetRowFooterCellText method.

    Returns the summary text displayed within a particular group row footer cell.

You may need to obtain the complete text displayed within a group row. For this purpose, call the GridView.GetGroupRowDisplayText method.

Expanded Example

The example below shows how to get the group summary values for the focused row by handling the ColumnView.FocusedRowChanged event. Summary items are displayed within the group row and the group footer. If the focused row is not a group row, we use the GridView.GetParentRowHandle method to obtain the group row that owns the focused row.

In order to display a group summary, you must add group summary items to the GridView.GroupSummary collection. To do this at design time, open the Group Summary Items Page, add items and customize them as displayed below.

The second item can be customized in the same manner. See the Summaries Overview topic for details on how summaries can be customized.

To add and customize group summary items at runtime, the following code can be used.

Here, the GridSummaryItem.DisplayFormat property is used for demonstration purposes only. To learn more about summary value formats, read the Format Summary Values topic.

To obtain summary values the GridView.GetGroupSummaryValues method is used.

Expanded See Also

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