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]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
   [Expand]Grouping
   [Expand]Sorting
   [Collapse]Summaries
     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]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]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]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Tutorial: Obtain Summary Values

This walkthrough is a transcript of the Obtain Summary Values video available on the DevExpress YouTube Channel.

The GridControl allows you to obtain summary values so you can use them in calculations or to customize grid Views. In this tutorial, you'll first see how you can format group rows based on their group summary values. Then, you will see how to obtain total summary values and use them to specify a different display text for footer cells.

Expanded Starting Point

Start with a GridControl that already has total and group summaries. A footer cell under the Order Sum column displays the average column value. The Unit Price column has two summaries that calculate the maximum and minimum column values. Group rows display the number of records in each group.

Expanded Obtaining Group Summary Values

Close the application. Select the View and handle its GridView.RowStyle event to specify the group row background color depending on group summary values. In the event handler, call the GridView.GetGroupSummaryValues method. This method returns the hash table containing values of all summaries for a specified group row. Since the grid only displays one group summary, simply obtain the first element from the View's GridView.GroupSummary collection. Use this value as the key value for the hash table to obtain the summary item value. If the obtained value is greater than 3, change the background color.

Run the application to see the result. Group rows whose summary values are greater than 3 are highlighted now.

Expanded Obtaining Total Summary Values

Now handle the GridView.CustomDrawFooterCell event to change the total summary display text. First, get the summary item being processed using event arguments. Then, obtain the summary value using the GridSummaryItem.SummaryValue property. Finally, generate a new display text, which includes the summary type, column caption and summary value, and assign this text to the event's parameter. The default painting mechanism will be invoked after event handler execution, and it will automatically display the modified text.

Run the application to see the result. All total summaries display the summary type, and target the column caption and formatted value.

Expanded See Also

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