Luv L

Luv L

  • 1.3k
  • 141
  • 7.2k

c# datagridview cells multiplications with sum

Oct 21 2014 3:09 AM
hi,

i used code for below datagridview cells sum
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  {
  int sum = 0;
  for (i = 0; i < dataGridView1.Rows.Count - 1; i++)
  {
  if (dataGridView1.Rows[i].Cells[0].Value != null)
  {
  sum += Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value.ToString());
  label1.Text = Convert.ToString(sum);
  }
  }
  }
  }
but i want to below like my cell[0].value sum is shown in label is ok ,but if i can use multipled by any numbers like below image the answer should be = 40
see below details how its come
5+4 = 9 * 2 = 18
(18+2) * 2 = 40





 





Answers (6)