如何在listview中对列进行求和 [英] How to sum columns in listview

查看:613
本文介绍了如何在listview中对列进行求和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮我解决这个问题吗?下面是我的代码,但它给了我错误。任何帮助将不胜感激。



Dim RowCol作为新整数()

Dim ColIndex作为ListViewItem

Dim Sum As Decimal = 0

尝试



如果Me.DailySalesListView.Items.Item(RowCol(0))。SubItems.Count - 1> = ColIndex.Index = 5然后

对于As Integer = 0 To DailySalesListView.FullRowSelect - 1

如果Me.DailySalesListView.Columns(a).Index.ToString.Trim()< > 然后

Sum + = Convert.ToDouble(Me.DailySalesListView.Items.Item(a).SubItems(0).Text)

结束如果

下一个

lblTotalBi.Text =总和

结束如果



Catch ex As Exception

MsgBox(算术运算期间出错,MsgBoxStyle.Critical,错误)

结束尝试



谢谢。

解决方案

看看这个:如何汇总VB.NET中listView中列的项目 [ ^ ]

Can anyone help me solve this problem? Below is my code but it gives me error. Any help will be appreciated.

Dim RowCol As New Integer()
Dim ColIndex As ListViewItem
Dim Sum As Decimal = 0
Try

If Me.DailySalesListView.Items.Item(RowCol(0)).SubItems.Count - 1 >= ColIndex.Index = 5 Then
For a As Integer = 0 To DailySalesListView.FullRowSelect - 1
If Me.DailySalesListView.Columns(a).Index.ToString.Trim() <> "" Then
Sum += Convert.ToDouble(Me.DailySalesListView.Items.Item(a).SubItems(0).Text)
End If
Next a
lblTotalBi.Text = Sum
End If

Catch ex As Exception
MsgBox("Error occured during arithmetic operation", MsgBoxStyle.Critical, "Error")
End Try

Thanks.

解决方案

Check this out: How to sumup items of a column in a listView in VB.NET[^]


这篇关于如何在listview中对列进行求和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆