How to customize the summary column for specific rows in WinForms GridGroupingControl?
Customize the summary row or column
You can customize the summary row descriptor to summarize the specific rows by using the QueryCellStyleInfo event in the WinForms GridGroupingControl. The reported scenario is achieved by customizing the SummaryFieldCell.
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
switch (e.TableCellIdentity.TableCellType)
{
case GridTableCellType.SummaryFieldCell:
{
if(e.TableCellIdentity.SummaryColumn.Name == "Data1")
{
e.Style.CellType = GridCellTypeName.FormulaCell;
e.Style.CellValue = "=SUM(B2:B5)"; //To summarize specific rows(First three rows)
}
break;
}
}
}Private Sub gridGroupingControl1_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
Select Case e.TableCellIdentity.TableCellType
Case GridTableCellType.SummaryFieldCell
If e.TableCellIdentity.SummaryColumn.Name = "Data1" Then
e.Style.CellType = GridCellTypeName.FormulaCell
e.Style.CellValue = "=SUM(B2:B5)" 'To summarize specific rows(First three rows)
End If
Exit Select
End Select
End SubIn the sample, the Summary is calculated for the first three rows.

Figure 1: Summary calculated for first three rows