本文介绍了如何在VB.NET中的listView中汇总列的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嗨所有........ 任何人都可以帮助如何总结列表视图的特定列 并将其值传递给VB.NET中的文本框? 希望有人可以帮助我.... 任何帮助都将是感谢... 请...帮助....:叹息:hi to all........Can anyone help on how to sumup a specific column of a listview and pass its value to a textbox in VB.NET?Hope someone can help me....Any help will be appreciate...pls...help.... :sigh:推荐答案 Dim dblTotal as Double = 0Dim dblTemp as DoubleFor Each lvItem As ListViewItem In ListView1.Items If Double.TryParse(lvItem.SubItems(2).Text, dblTemp) Then dblTotal += dblTemp End IfNextTextBox1.Text = dblTotal 但你必须知道第一列也是一个subItem,所以上面的代码将总结第3列中的值。我还投入了TryParse方法,因为你需要检查并确保该列中实际存在双精度数。 (当然,如果它是数据绑定并且列是双列,那么你就不需要了。But you have to know that the first column is also a subItem so the code above would sum up the values in column 3. I also threw in the TryParse method because you need to check and make sure that there are actually doubles in that column. (Of course if it's databound and the column is a Double column, then you wouldn't need that. Dim Li as ListViewItemDim dblTotal As DoubleFor Each Li In ListView1.Items If ListView1.Items.Count = 0 Then dblTotal = 0 ElsedblTotal = dblTotal + CCur(Li.SubItems(4)) End IfNext 我认为应该有效(显然可根据您的需求进行编辑!) 标记是否有用。I think should work (obviously edit for your needs!)Mark up if helpful. 这篇关于如何在VB.NET中的listView中汇总列的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-16 23:03