The Bogemic Grid control provides the following aggregate functions to work with ranges: AvgRange, SumRange, MaxRange, MinRange, CountRange. |
| ' calculate the sum of values in the first column Set range = grid.Range("A1:A10") sumRange = grid.SumRange(range) ' to do the same as one function call, use the SUM function sumRange = SUM("A1:A10") |
| ' the first column will contain the product names ' and the second column will contain prices grid.Cell("A",0) = "Title" ' set format and data type for the entire column "B" grid.Column("B").Property(Prop_Format) = "$%.ff" grid.Column("B").Property(Prop_DataType) = DataType_R4 ' .. except the first cell grid.Cell("B",0).Property(Prop_DataType) = DataType_BStr grid.Cell("B",0).Property(Prop_Format) = "" grid.Cell("B",0) = "Price" ' fill the order with data grid.Cell("A",1).Value = "Britney Spears Audio CD" grid.Cell("B",1).Value = 12.99 grid.Cell("A",2).Value = "Celine Dion Blu-ray" grid.Cell("B",2).Value = 15.95 grid.Cell("A",3).Value = "Alicia Keys Album" grid.Cell("B",3).Value = 7.99 ' set text align grid.Property(Prop_VAlign) = VAlign_Center grid.Column("A").Property(Prop_HAlign)=HAlign_Left grid.Column("B").Property(Prop_HAlign)=HAlign_Right grid.Row(0).Property(Prop_HAlign)=HAlign_Center ' add total sum grid.Row(4).Property(Prop_BorderTop)=1 grid.Cell("A",4).Property(Prop_HAlign)=HAlign_Right grid.Cell("A",4).Value = "Total:" ' and finally, insert a formula to calculate the total sum grid.Cell("B",4).Property(Prop_Formula) = "=SUM(""B2:B4"")" |
![]() |
| « Back | Up | Forward » |
| © 2008 Bogemic Software. All rights reserved. All names are property of their respective owners. |