# DataGridViewSummaryRow

Adds a new method to the DataGridView to automatically generate subtotal and summary rows using several different aggregation models.

{% hint style="danger" %}
This extension is not needed anymore for Wisej 2.5+ as its functionality has been fully integrated into the core Wisej Framework.
{% endhint %}

{% embed url="<https://github.com/iceteagroup/wisej-extensions/tree/master/Wisej.Web.Ext.DataGridViewSummaryRow>" %}
DataGridViewSummaryRow Source Code
{% endembed %}

## How to Use

To add the values in colSales, grouped by the columns from colRegion to colCountry.

{% tabs %}
{% tab title="C#" %}

```csharp
this.dataGridView1.AddSummaryRows(
    SummaryType.Sum, 
    SummaryRowPosition.Above, 
    this.colRegion, 
    this.colCountry, 
    this.colSales, 
    style);
```

{% endtab %}

{% tab title="VB.NET" %}

```php
Me.dataGridView1.AddSummaryRows( _
    SummaryType.Sum, _
    SummaryRowPosition.Above, _
    this.colRegion, _
    this.colCountry, _
    this.colSales, _
    style)
```

{% endtab %}
{% endtabs %}

Call multiple times to aggregate different columns. It will add the subtotal to the same summary row that matches the group. You can create multiple parent summaries using [SummaryRowPosition.Parent](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.datagridviewsummaryrow.datagridviewsummaryrow#summaryposition).

The method returns an array of [DataGridViewSummaryRow ](https://docs.wisej.com/extensions/extensions/datagridviewsummaryrow)rows that you can post process. You can also either pass a DataGridViewCellStyle to the [AddSummaryRows ](https://docs.wisej.com/extensions/extensions/api/wisej.web.ext.datagridviewsummaryrow.datagridviewsummaryrowextensions#addsummaryrows-grid-summarytype-groupcol-summarycol-style)method or assign it directly to the newly added rows.
