How to update the table summary in WinForms DataGrid (SfDataGrid) ?
In WinForms DataGrid, you can update the summary values when you are editing the cell value by overriding OnInitializeEditElement method and SfNumericTextBox.TextChanged event in GridNumericCellRenderer.
this.sfDataGrid.CellRenderers.Remove("Numeric");
this.sfDataGrid.CellRenderers.Add("Numeric", new GridNumericCellRendererExt(this.sfDataGrid));public class GridNumericCellRendererExt : GridNumericCellRenderer
{
RowColumnIndex RowColumnIndex { get; set; }
SfDataGrid DataGrid { get; set; }
public GridNumericCellRendererExt(SfDataGrid dataGrid)
{
this.DataGrid = dataGrid;
}
protected override void OnInitializeEditElement(DataColumnBase column, RowColumnIndex rowColumnIndex, SfNumericTextBox uiElement)
{
base.OnInitializeEditElement(column, rowColumnIndex, uiElement);
uiElement.TextChanged += UiElement_TextChanged;
this.RowColumnIndex = rowColumnIndex;
}
private void UiElement_TextChanged(object sender, EventArgs e)
{
UpdateSummaryValues(this.RowColumnIndex.RowIndex, this.RowColumnIndex.ColumnIndex);
}
private void UpdateSummaryValues(int rowIndex, int columnIndex)
{
string editEelementText = string.IsNullOrEmpty(this.CurrentCellRendererElement.Text) ? "0" : this.CurrentCellRendererElement.Text;
columnIndex = this.TableControl.ResolveToGridVisibleColumnIndex(columnIndex);
if (columnIndex < 0)
return;
var mappingName = DataGrid.Columns[columnIndex].MappingName;
var recordIndex = this.TableControl.ResolveToRecordIndex(rowIndex);
if (recordIndex < 0)
return;
if (DataGrid.View.TopLevelGroup != null)
{
var record = DataGrid.View.TopLevelGroup.DisplayElements[recordIndex];
if (!record.IsRecords)
return;
var data = (record as RecordEntry).Data;
data.GetType().GetProperty(mappingName).SetValue(data, (int.Parse(editEelementText)));
}
else
{
var record1 = DataGrid.View.Records.GetItemAt(recordIndex);
record1.GetType().GetProperty(mappingName).SetValue(record1, (int.Parse(editEelementText)));
}
}
}

Conclusion
I hope you enjoyed learning about how to update the table summary in WinForms DataGrid (SfDataGrid).
You can refer to our WinForms DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms DataGrid example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!