[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [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
   [Collapse]Get Started With Data Grid and Views
     [Expand]Appearance and Conditional Formatting
     [Expand]Data Editing
     [Expand]Hit Information
     [Expand]Data Binding and Working with Columns
     [Expand]Grid View - Columns, Rows and Cells
     [Expand]Banded Views
     [Expand]WinExplorer View
     [Expand]Tile View
     [Expand]Filter and Search
       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
     [Expand]Split Presentation
     [Expand]Row Preview Sections
   [Expand]Data Binding
    Unbound Columns
   [Expand]Data Editing and Validation
   [Expand]Filter and Search
   [Expand]Focus and Selection Handling
    Format Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
    Split Presentation
    Row Preview Sections
   [Expand]Batch Modifications
    Hit Information
    Popup Menus
   [Expand]Save and Restore Layout
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [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]Sunburst 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]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

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

Is this topic helpful?​​​​​​​