ComponentOne FlexGrid for WinForms
SubtotalEventArgs Class
Members  Example 

C1.Win.C1FlexGrid Namespace : SubtotalEventArgs Class
Provides data for the C1FlexGridBase.BeforeSubtotal and C1FlexGridBase.AfterSubtotal events.
Object Model
SubtotalEventArgs ClassCellStyle Class
Syntax
'Declaration
 
Public Class SubtotalEventArgs 
   Inherits System.EventArgs
public class SubtotalEventArgs : System.EventArgs 
Remarks
Example
private void Form1_Load(object sender, EventArgs e)
{
            _flex = new C1FlexGrid();
            _flex.Dock = DockStyle.Fill;
            this.Controls.Add(_flex);
            OleDbConnection con = new OleDbConnection("provider=microsoft.jet.oledb.4.0;Data Source=" + Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\ComponentOne Samples\\Common\\C1NWind.mdb");
            DataTable productsTable = new DataTable();
            new OleDbDataAdapter("Select * from Products order by CategoryID", con).Fill(productsTable);
            _flex.DataSource = productsTable;
            _flex.BeforeSubtotal += _flex_BeforeSubtotal;
            _flex.Tree.Column = 1;
            _flex.Tree.Style = TreeStyleFlags.Simple;
            _flex.Subtotal(AggregateEnum.Average, 0, "CategoryID", "UnitsOnOrder" , "Average for the Category {0}");
}

private void _flex_BeforeSubtotal(object sender, SubtotalEventArgs e)
{
            //Customizing the aggregate to exclude cells having 0 value from average calculation
            int nonZeroRows = 0;
            if (_flex.Cols[e.TotalOn].Name == "UnitsOnOrder")
            {
                for (int row = e.Top; row < e.Bottom; row++)
                {
                    if (_flex[row, e.TotalOn].ToString() != "0")
                        nonZeroRows++;
                }
            }
            int noOfRowsInGrp = (e.Bottom - e.Top)+1;
            double value = Convert.ToDouble(e.AggregateValue);
            if (nonZeroRows == 0)
            {
                e.AggregateValue = 0;
                return;
            }
            e.AggregateValue = (value*noOfRowsInGrp)/ nonZeroRows;
}
Inheritance Hierarchy

System.Object
   System.EventArgs
      C1.Win.C1FlexGrid.SubtotalEventArgs

See Also

Reference

SubtotalEventArgs Members
C1.Win.C1FlexGrid Namespace