public Form1()
{
InitializeComponent();
this.dataGridView5.CellValueChanged += new DataGridViewCellEventHandler(dataGridView5_CellValueChanged);
this.dataGridView5.RowsRemoved += new DataGridViewRowsRemovedEventHandler(dataGridView5_RowsRemoved);
}
Code (C#)
private int GetVat()
{
int sum = 0, intvalue;
sum = Convert.ToInt32(dataGridView5.Rows[0].Cells[13].Value);
foreach (DataGridViewRow row in this.dataGridView5.Rows)
{
if (row.Cells[23].Value != null)
{
if (Int32.TryParse(row.Cells[23].Value.ToString(), out intvalue))
{
sum = sum+intvalue;
}
}
}
return sum;
}