# C1.Win.FlexGrid.C1FlexGridBase.Aggregate

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate*">Aggregate Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_C1_Win_FlexGrid_AggregateEnum_C1_Win_FlexGrid_CellRange_C1_Win_FlexGrid_AggregateFlags_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate(C1.Win.FlexGrid.AggregateEnum,C1.Win.FlexGrid.CellRange,C1.Win.FlexGrid.AggregateFlags)">Aggregate(AggregateEnum, CellRange, AggregateFlags)</h4>
<div class="markdown level1 summary"><p>Calculates aggregate statistics for a range.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public double Aggregate(AggregateEnum aggType, CellRange rg, AggregateFlags flags)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Aggregate(aggType As AggregateEnum, rg As CellRange, flags As AggregateFlags) As Double</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.AggregateEnum.html">AggregateEnum</a></td>
      <td><span class="parametername">aggType</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.AggregateEnum.html">AggregateEnum</a> value that specifies the type of aggregate to calculate.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.CellRange.html">CellRange</a></td>
      <td><span class="parametername">rg</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.CellRange.html">CellRange</a> object that contains the values to be aggregated.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.AggregateFlags.html">AggregateFlags</a></td>
      <td><span class="parametername">flags</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.AggregateFlags.html">AggregateFlags</a> value that specifies aggregation options.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></td>
      <td><p>A <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a> that represents the aggregate value.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_C1_Win_FlexGrid_AggregateEnum_System_Int32_System_Int32_System_Int32_System_Int32_C1_Win_FlexGrid_AggregateFlags_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate(C1.Win.FlexGrid.AggregateEnum,System.Int32,System.Int32,System.Int32,System.Int32,C1.Win.FlexGrid.AggregateFlags)">Aggregate(AggregateEnum, int, int, int, int, AggregateFlags)</h4>
<div class="markdown level1 summary"><p>Calculates aggregate statistics for a range.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public double Aggregate(AggregateEnum aggType, int topRow, int leftCol, int bottomRow, int rightCol, AggregateFlags flags)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Aggregate(aggType As AggregateEnum, topRow As Integer, leftCol As Integer, bottomRow As Integer, rightCol As Integer, flags As AggregateFlags) As Double</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.AggregateEnum.html">AggregateEnum</a></td>
      <td><span class="parametername">aggType</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.AggregateEnum.html">AggregateEnum</a> value that specifies the type of aggregate to calculate.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">topRow</span></td>
      <td><p>Top row in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">leftCol</span></td>
      <td><p>Left column in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">bottomRow</span></td>
      <td><p>Bottom row in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">rightCol</span></td>
      <td><p>Right column in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.AggregateFlags.html">AggregateFlags</a></td>
      <td><span class="parametername">flags</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.AggregateFlags.html">AggregateFlags</a> value that specifies aggregation options.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></td>
      <td><p>A <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a> that represents the aggregate value.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_C1_Win_FlexGrid_AggregateEnum_C1_Win_FlexGrid_AggregateFlags_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate(C1.Win.FlexGrid.AggregateEnum,C1.Win.FlexGrid.AggregateFlags)">Aggregate(AggregateEnum, AggregateFlags)</h4>
<div class="markdown level1 summary"><p>Calculates aggregate statistics for the selection.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public double Aggregate(AggregateEnum aggType, AggregateFlags flags)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Aggregate(aggType As AggregateEnum, flags As AggregateFlags) As Double</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.AggregateEnum.html">AggregateEnum</a></td>
      <td><span class="parametername">aggType</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.AggregateEnum.html">AggregateEnum</a> value that specifies the type of aggregate to calculate.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.AggregateFlags.html">AggregateFlags</a></td>
      <td><span class="parametername">flags</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.AggregateFlags.html">AggregateFlags</a> value that specifies aggregation options.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></td>
      <td><p>A <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a> that represents the aggregate value.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_C1_Win_FlexGrid_AggregateEnum_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate(C1.Win.FlexGrid.AggregateEnum)">Aggregate(AggregateEnum)</h4>
<div class="markdown level1 summary"><p>Calculates aggregate statistics for the selection.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public double Aggregate(AggregateEnum aggType)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Aggregate(aggType As AggregateEnum) As Double</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.AggregateEnum.html">AggregateEnum</a></td>
      <td><span class="parametername">aggType</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.AggregateEnum.html">AggregateEnum</a> value that specifies the type of aggregate to calculate.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></td>
      <td><p>A <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a> that represents the aggregate value.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_C1_Win_FlexGrid_AggregateEnum__examples">Examples</h5>
<p>The code below <a class="xref" href="C1.Win.FlexGrid.C1FlexGridBase.Aggregate.html#C1_Win_FlexGrid_C1FlexGridBase_Aggregate_C1_Win_FlexGrid_AggregateEnum_C1_Win_FlexGrid_CellRange_C1_Win_FlexGrid_AggregateFlags_">Aggregate(AggregateEnum, CellRange, AggregateFlags)</a> method to calculate aggregate statistics
for the selection. Whenever the selection changes, new aggregates are
calculated and written to the console.</p>
<pre><code class="lang-csharp">void flex_SelChange(object sender, System.EventArgs e)
{
  string fmt = "Count {0:0}, Sum {1:#,##0.00}, " +
               "Avg {2:#,##0.00}, Stdev {3:#,##0.00}";
  Console.WriteLine(fmt,
    flex.Aggregate(AggregateEnum.Count),
    flex.Aggregate(AggregateEnum.Sum),
    flex.Aggregate(AggregateEnum.Average),
    flex.Aggregate(AggregateEnum.Std));
}</code></pre>



<a id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_C1_Win_FlexGrid_AggregateEnum_C1_Win_FlexGrid_CellRange_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate(C1.Win.FlexGrid.AggregateEnum,C1.Win.FlexGrid.CellRange)">Aggregate(AggregateEnum, CellRange)</h4>
<div class="markdown level1 summary"><p>Calculates aggregate statistics for a range.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public double Aggregate(AggregateEnum aggType, CellRange rg)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Aggregate(aggType As AggregateEnum, rg As CellRange) As Double</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.AggregateEnum.html">AggregateEnum</a></td>
      <td><span class="parametername">aggType</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.AggregateEnum.html">AggregateEnum</a> value that specifies the type of aggregate to calculate.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.CellRange.html">CellRange</a></td>
      <td><span class="parametername">rg</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.CellRange.html">CellRange</a> object that contains the values to be aggregated.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></td>
      <td><p>A <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a> that represents the aggregate value.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate*"></a>
<h4 id="C1_Win_FlexGrid_C1FlexGridBase_Aggregate_C1_Win_FlexGrid_AggregateEnum_System_Int32_System_Int32_System_Int32_System_Int32_" data-uid="C1.Win.FlexGrid.C1FlexGridBase.Aggregate(C1.Win.FlexGrid.AggregateEnum,System.Int32,System.Int32,System.Int32,System.Int32)">Aggregate(AggregateEnum, int, int, int, int)</h4>
<div class="markdown level1 summary"><p>Calculates aggregate statistics for a range.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public double Aggregate(AggregateEnum aggType, int topRow, int leftCol, int bottomRow, int rightCol)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Aggregate(aggType As AggregateEnum, topRow As Integer, leftCol As Integer, bottomRow As Integer, rightCol As Integer) As Double</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.Win.FlexGrid.AggregateEnum.html">AggregateEnum</a></td>
      <td><span class="parametername">aggType</span></td>
      <td><p><a class="xref" href="C1.Win.FlexGrid.AggregateEnum.html">AggregateEnum</a> value that specifies the type of aggregate to calculate.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">topRow</span></td>
      <td><p>Top row in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">leftCol</span></td>
      <td><p>Left column in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">bottomRow</span></td>
      <td><p>Bottom row in the range.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">rightCol</span></td>
      <td><p>Right column in the range.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a></td>
      <td><p>A <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.double">double</a> that represents the aggregate value.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
