I want to get the sum of a column of datagridview and show that in textbox. After each entry the sum should be changed dynamically. For that I am using textChanged event of
private void dataGridView2_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == 5)
{
summition();
}
}
void summition()
{
double sum = 0;
foreach (DataGridViewRow row in dataGridView2.Rows)
{
if(!row .IsNewRow )
sum += Convert.ToDouble(row.Cells [5].Value .ToString () );
}
textBox9.Text = sum.ToString();
}