FlexGrid for WinForms | ComponentOne
C1.Win.C1FlexGrid Namespace / C1FlexGrid Class / Subtotal Method / Subtotal(AggregateEnum,Int32,Int32,Int32,Int32,String,AggregateFlags) Method
AggregateEnum value that specifies the type of aggregate to calculate.
Outline level to assign to the new subtotal rows. This parameter allows the creation of multi-level subtotals and affects the display of the outline tree.
First column in the range used to detect group breaks.
Last column in the range used to detect group breaks.
Column that contains values to be aggregated (usually numeric).
Text to insert in the subtotal rows.
Options to use when calculating the aggregates.

In This Topic
    Subtotal(AggregateEnum,Int32,Int32,Int32,Int32,String,AggregateFlags) Method
    In This Topic
    Groups rows based on cell contents and calculates aggregate values.
    Syntax
    'Declaration
     
    
    Public Overloads Sub Subtotal( _
       ByVal aggType As AggregateEnum, _
       ByVal level As Integer, _
       ByVal groupFrom As Integer, _
       ByVal groupTo As Integer, _
       ByVal totalOn As Integer, _
       ByVal caption As String, _
       ByVal options As AggregateFlags _
    ) 

    Parameters

    aggType
    AggregateEnum value that specifies the type of aggregate to calculate.
    level
    Outline level to assign to the new subtotal rows. This parameter allows the creation of multi-level subtotals and affects the display of the outline tree.
    groupFrom
    First column in the range used to detect group breaks.
    groupTo
    Last column in the range used to detect group breaks.
    totalOn
    Column that contains values to be aggregated (usually numeric).
    caption
    Text to insert in the subtotal rows.
    options
    Options to use when calculating the aggregates.
    Remarks

    The C1.Win.C1FlexGrid.C1FlexGridBase.Subtotal(C1.Win.C1FlexGrid.AggregateEnum,System.Int32,System.Int32,System.Int32,System.Int32,System.String,C1.Win.C1FlexGrid.AggregateFlags,C1.Win.C1FlexGrid.RowColFlags) method inserts rows containing aggregate values. These new rows are set to behave as tree nodes so they can be collapsed and expanded to display a dynamic hierarchical outline.

    You can control the appearance and behavior of the outline tree using the C1FlexGridBase.Tree property.

    The node rows added by the C1.Win.C1FlexGrid.C1FlexGridBase.Subtotal(C1.Win.C1FlexGrid.AggregateEnum,System.Int32,System.Int32,System.Int32,System.Int32,System.String,C1.Win.C1FlexGrid.AggregateFlags,C1.Win.C1FlexGrid.RowColFlags) method have their RowCol.Style property automatically set to one of the Styles.Subtotal* styles. You can use the C1FlexGridBase.Styles collection to modify the appearance of all subtotal rows on the grid.

    To create an outline tree manually, insert node rows using the RowCollection.InsertNode method, or convert regular rows into nodes by setting the Row.IsNode property to true for the node rows. Then use the Node.Level property to set the outline level for the new nodes.

    Example

    The code below assumes a grid with four columns: "Product", "Region", "Employee", and "Sales".

    The code groups on the first two columns, calculating total sales for each product and for each region within each product.

    If the user drags a column to a new position, the tree is automatically rebuilt to show the new grouping (by Employee, Region, etc).

    See Also