-
March 10th, 2015, 02:58 AM
#1
ListView groups with totals and subtotals
Hi.
I have a ListView with groups.
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.
-
March 10th, 2015, 07:47 AM
#2
Re: ListView groups with totals and subtotals
1) you'll need to make the subtotals yourself. this isn't goign to go "automatically"
If this needs to be at the bottom, then either:
- enable the group footer and put the subtotal in there.
THis may not be visually entirely what you want since it won't be aligned with the columns.
- or add a subtotal item to the group
2) there's no provision in listcontrol for a grand total
you can add an extra "total" group and add a total item
or
have the total displayed outside of the listcontrol.
-
March 11th, 2015, 09:01 AM
#3
Re: ListView groups with totals and subtotals
Thank you.
I find the solution
' 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()
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
|