Link to home
Start Free TrialLog in
Avatar of Gabriel_Brienza
Gabriel_Brienza

asked on

How can summarize item in a listview

I have the following 2 field in a grid
GRID
====
GroupField   TotalField
AAA            1
BBB            1
CCC            1
AAA            1
BBB            2
CCC            1
AAA            1
BBB            1
================
Now i need to provide a summary in a listview as follows

GroupField   TotalField
AAA             3
BBB            4
CCC            2
==========================

I have done the following


Private sub SetupListview

      with lvw.ColumnHeaders
          .Clear
          .Add, "Grp","Group,2000
            .Add, "Ttl","Total,2000
 
      end with
end sub

Private sub PopulateListView(Byval strGroup as string,intValue as integer)
      dim li as listItem
        dim liKey as string

liKey="k" & StrGroup
      if lvw.listitems.count > 0 Then
      

            for each li in lvw.listitems
                  if li.text=strGroup then
                        li.subItems(1)=IntValue + 1
                  else
                        SET LI=LVW.ListItems.Add(,likey,strGroup)
                        li.subItems(1)=IntValue
                  end if
            next
      else
            
            SET LI=LVW.ListItems.Add(,likey,strGroup)
            li.subItems(1)=IntValue
      end if

end sub
ASKER CERTIFIED SOLUTION
Avatar of Shiju S
Shiju S
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gabriel_Brienza
Gabriel_Brienza

ASKER

fantastic .it worked very well