我怎么能显示在一个DataGridView列的总和? [英] how I can show the sum of in a datagridview column?
本文介绍了我怎么能显示在一个DataGridView列的总和?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要显示的总和计数
此 datagridview的列
,但我不知道该怎么我能到在DataGridView中的数据。
当我按一下按钮,我想说明 94
在卷标1
。
如何才能做到这一点?
解决方案
INT总和= 0;
的for(int i = 0; I< dataGridView1.Rows.Count ++ I)
{
总和+ = Convert.ToInt32(dataGridView1.Rows [I] .Cells [1]。价值);
}
label1.text = sum.ToString();
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 click on the button, I want to show 94
in label1
.
How can this be done?
解决方案
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();
这篇关于我怎么能显示在一个DataGridView列的总和?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文