有关C#中的ListView

qjq_19891013 2009-12-14 09:06:04
俺是初学者哦!!!
我的窗体中有个ListView控件,其中有一列是算钱的,“费用”,如何做一个小计,即是专门算“费用”总和的项,这个“小计”在总是在ListView最底端,它对应的“费用”这一列随着随着(费用)信息的多少而增加
...全文
114 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
别递烟哥不会 2009-12-14
  • 打赏
  • 举报
回复
先求出和,在在listview最低端添加一行,并赋值
个人想法
abaochan 2009-12-14
  • 打赏
  • 举报
回复
foreach(ListViewItem it in ListView1.Items)
{
count+=double.parse(it.SubItems[1].Text);
}
ListViewItem last=new listviewitem();
last.text="合计:";
ListViewItem sub=new listviewitem();
sub.text=count.tostring();
last.subitems.add(sub);
ListView1.Items.add(last);
试下这个
flyerwing 2009-12-14
  • 打赏
  • 举报
回复
LZ是来气人地,你试了没?
试过了就知道成不成了!
liweining123 2009-12-14
  • 打赏
  • 举报
回复
思路学习了!
cicigl 2009-12-14
  • 打赏
  • 举报
回复
那就listview添加一行,这行你让它总是显示在最底部,然后每次读取数据就先删除这行,然后再添加一次,算一下小计,不就行了么。
flyerwing 2009-12-14
  • 打赏
  • 举报
回复
可以的!
偶一直都这么用的
qjq_19891013 2009-12-14
  • 打赏
  • 举报
回复
不行耶……
flyerwing 2009-12-14
  • 打赏
  • 举报
回复
foreach(ListViewItem it in ListView1.Items)
{
count+=double.parse(it.SubItems[1].Text);
}
ListViewItem last=new listviewitem();
last.text="合计:";
ListViewItem sub=new listviewitem();
sub.text=count.tostring();
last.subitems.add(sub);
ListView1.Items.add(last);
试下这个

flyerwing 2009-12-14
  • 打赏
  • 举报
回复
columns
items
subitems
这几个搞明白估计可以吧
liyijiangh 2009-12-14
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 qjq_19891013 的回复:]
是显示在ListView中的最底部哦!!!而不是超出ListView的范围…………
[/Quote]那估计只能自定义控件了
qjq_19891013 2009-12-14
  • 打赏
  • 举报
回复
是显示在ListView中的最底部哦!!!而不是超出ListView的范围…………
liyijiangh 2009-12-14
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 qjq_19891013 的回复:]
那个算钱的count也在ListView当中,属于"费用"这一列,但是ListView还有一项在最底端,对应第一列是”“小计”,对应“费用”是他们总和
[/Quote]晕了 反正就是求第几列总和 动态显示到最下面?那就判断
qqiuzaihui 2009-12-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 liyijiangh 的回复:]
循环 得到第一列费用总和 然后下面放个label 添加的话赋值label
double count=0;
foreach(ListViewItem it in ....Items)
{
    count+=double.parse(it.SubItems[0].Text);
}
label1.Text=count.ToString();
个人想法
[/Quote]
UP, 之前我就是用这种方法.
qjq_19891013 2009-12-14
  • 打赏
  • 举报
回复
那个算钱的count也在ListView当中,属于"费用"这一列,但是ListView还有一项在最底端,对应第一列是”“小计”,对应“费用”是他们总和
liyijiangh 2009-12-14
  • 打赏
  • 举报
回复
循环 得到第一列费用总和 然后下面放个label 添加的话赋值label
double count=0;
foreach(ListViewItem it in ....Items)
{
count+=double.parse(it.SubItems[0].Text);
}
label1.Text=count.ToString();
个人想法

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧