Sameer Farooqui

Sameer Farooqui

  • NA
  • 58
  • 3.5k

Looping through datagridview column cell

Aug 29 2022 9:10 AM

I want to perform addition of the total cell. however, it is giving value of latest cell added. Attached the screenshot of gridview:

 

Gridview

private void dataGridView1_CellValueChanged_1(object sender, DataGridViewCellEventArgs e)
        {

if (dataGridView1["Total", e.RowIndex].Value != null)
                
            {

                for (int i =0; i < dataGridView1.Rows.Count; i++)
                { 
                double grandtotal = Convert.ToDouble(dataGridView1["Total", e.RowIndex].Value);
                txtboxGrandTotal.Text = grandtotal.ToString();
                    }
            }

}


Answers (2)