汇总列 [英] Summing columns
本文介绍了汇总列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好.
我有带有"cCommonPrice"单元格的datagridview.我正在尝试label.text在此单元格中显示日期的总和
这是我的代码
hello.
i have datagridview with ''cCommonPrice'' cell. im trying to label.text show sum of date in this cell
this my code
private void btnSell_Click(object sender, EventArgs e)
{
if (Program.myList.Contains(txtBarCode.Text))
{
SelectProduct(txtBarCode.Text);
}
for (int i = 0; i < dgvProducts.Rows.Count; i++)
{
decimal mon = 0;
decimal comPrice;
comPrice = (decimal)dgvProducts.Rows[i].Cells["cPrice"].Value;
mon = comPrice;
mon = mon + comPrice;
lblPrice.Text = mon.ToString();
}
txtQuantity.ResetText();
txtBarCode.ResetText();
}
但这不起作用
我需要帮助总结
我正在使用C#Winforms
datagridview源不是sql table
but it does not work
i need help for summing
Im using c# winforms
datagridview source is not sql table
推荐答案
我认为您的代码中存在一些问题.写这样的东西
I think there is some problem in your code. Write something like this
decimal mon = 0;
decimal comPrice;
for (int i = 0; i < dgvProducts.Rows.Count; i++)
{
try
{
comPrice = (decimal)dgvProducts.Rows[i].Cells["cPrice"].Value;
mon += comPrice;
}
catch(Exception e)
{}
}
lblPrice.Text = mon.ToString();
这篇关于汇总列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文