-
Mar 9th, 2015, 01:19 PM
#1
Thread Starter
Member
ListView groups with totals and subtotals
Hi.
I have a ListView with groups.
Some groups have columns with prices.
How I can do subtotals and totals at the end of every column and any group?
Any example?
Thank you.
Last edited by makisbest; Mar 9th, 2015 at 01:24 PM.
-
Mar 9th, 2015, 06:31 PM
#2
Re: ListView groups with totals and subtotals
You appear to think that there's some magic to it. There isn't. You do the arithmetic and then add another item to the group.
-
Mar 10th, 2015, 03:04 AM
#3
Thread Starter
Member
Re: ListView groups with totals and subtotals
OK, I agree... but how?? I am new to all this stuff.
-
Mar 10th, 2015, 03:26 AM
#4
Re: ListView groups with totals and subtotals
Originally Posted by makisbest
OK, I agree... but how?? I am new to all this stuff.
I'm going to give you the benefit of the doubt and assume that you know how to do the arithmetic. As for adding the item, I would expect that you would already know how to do that because you must already have items in there if you have something to total. I'm confused as to where the actual issue is. If you're just waiting for someone to write the code for you then I'm not your man. If you have thought through what you need to do and, even better, had a go at doing it, then I'm more than happy to address a specific issue.
-
Mar 10th, 2015, 06:24 AM
#5
Thread Starter
Member
Re: ListView groups with totals and subtotals
I make it work.... Thank you for the help.
Code:
' Add a group with totals
Dim TotalSum, TotalSum1 As Double
Dim TempDbl As Double
TotalSum = 0
TotalSum1 = 0
For Each strmyGroupname In ListView1.Items
If Double.TryParse(strmyGroupname.SubItems(7).Text, TempDbl) Then TotalSum += TempDbl
If Double.TryParse(strmyGroupname.SubItems(8).Text, TempDbl) Then TotalSum1 += TempDbl
Next
Dim gp As ListViewGroup
gp = New ListViewGroup("total", "total")
ListView1.Groups.Add(gp)
Dim Item1 As New ListViewItem
Item1 = ListView1.Items.Add("total:", 0)
Item1.SubItems.Add("")
Item1.SubItems.Add("")
Item1.SubItems.Add("")
Item1.SubItems.Add("")
Item1.SubItems.Add("")
Item1.SubItems.Add("")
Item1.SubItems.Add(TotalSum)
Item1.SubItems.Add(TotalSum1)
Item1.Group = gp
ListView1.Update()
ListView1.EndUpdate()
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|