如何从listview控件中获取列总计 [英] how to get column totals from listview control
本文介绍了如何从listview控件中获取列总计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码片段
在listView中添加一列并在ac#form上的标签中显示
。
I have the following piece of code which
adds up a column in a listView and displays
in a label on a c# form.
Decimal iSum = 0;
foreach (ListViewItem o in this.listView3.Items)
{
iSum = iSum + Convert.ToDecimal(o.SubItems[1].Text);
}
label2.Text = iSum.ToString();
如何再获得两列总数来自listView?
How can I get two more column totals from the listView ?
推荐答案
使用相同的逻辑。
Use the same logic.
iSum = iSum + Convert.ToDecimal(o.SubItems[1].Text) + Convert.ToDecimal(o.SubItems[2].Text);
//or
iSum2 = iSum2 + Convert.ToDecimal(o.SubItems[2].Text);
这篇关于如何从listview控件中获取列总计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文