how I can show the sum of in a datagridview column?

后端 未结 8 1480
日久生厌
日久生厌 2020-11-27 05:46

I need to show the sum of the count column from this datagridview, but I don\'t know how I can get to the data in the datagridview.

When I

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 06:37

    int sum = 0;
    for (int i = 0; i < dataGridView1.Rows.Count; ++i)
    {
        sum += Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value);
    }
    label1.Text = sum.ToString();
    

提交回复
热议问题