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

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

    Use LINQ if you can.

      label1.Text =  dataGridView1.Rows.Cast()
                                       .AsEnumerable()
                                       .Sum(x => int.Parse(x.Cells[1].Value.ToString()))
                                       .ToString();
    

提交回复
热议问题