 ---------------------------------------------------
|                                                   |
| Group Row Sum Manager                             |
|                                                   |
| iGrid.NET Extra Samples                           |
| Copyright (c) 10Tec Company                       |
| All rights reserved                               |
|                                                   |
| Available editions:                               |
| >> iGrid.NET 2.5, VS2005 C#/VB.NET                |
|                                                   |
 ---------------------------------------------------

Description:
============
In many cases we need to display totals for the values in a column in the group rows when the grid is grouped. This sample gives you an easy-to-use class you can use with iGrid.NET for that.

To use this class called iGGroupRowSumManager, add it to your project (it is implemented in a separate file), declare a variable which stores a new instance of this class on the form level, and call its Attach method to attach the manager to the require grid. For instance, if you have a GRSM var of the iGGroupRowSumManager object type, it will look like the following:

GRSM.Attach(iGrid1, "int3")

The first parameter is the grid you attach the manager to, the second one is the string key of the column to calculate the sum of. That's all  after that the Group Row Sum Manager will calculate the sum of the specified column automatically after any grouping operation.


Short Code Explanation:
=======================
The iGGroupRowSumManager class adds two event handlers, AfterContentsGrouped and CustomDrawCellForeground, for the specified iGrid. The heart of the iGGroupRowSumManager class is implemented in the AfterContentsGrouped event  the class calculates the sum of the specified column there.

The CustomDrawCellForeground event is used to display the contents of the group rows using our custom drawn format. First we display the standard contents of a group row using the standard font, and after that we draw the total value using the bold font.

The structure of the class allows you to easily extend it to calculate such total functions as COUNT, MAX, etc. This also can be done not only for one column but for several ones.
