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

后端 未结 8 1492
日久生厌
日久生厌 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:29

     decimal Total = 0;
    
    for (int i = 0; i < dataGridView1.Rows.Count; i++)
    {
        Total+= Convert.ToDecimal(dataGridView1.Rows[i].Cells["ColumnName"].Value);
      }
    
    labelName.Text = Total.ToString();
    

提交回复
热议问题