下面的示例展示了如何创建两个分组汇总项。 第一个汇总项表示分组内记录的总数,并显示在分组行中。 第二个汇总项计算 UnitPrice 字段的合计,并显示在分组脚注内、 Unit Price 列下面。 代码的运行结果如下图所示:
C# | 复制代码 |
---|
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid;
gridView1.GroupFooterShowMode = GroupFooterShowMode.VisibleAlways;
GridGroupSummaryItem item = new GridGroupSummaryItem();
item.FieldName = "ProductName";
item.SummaryType = DevExpress.Data.SummaryItemType.Count;
gridView1.GroupSummary.Add(item);
GridGroupSummaryItem item1 = new GridGroupSummaryItem();
item1.FieldName = "UnitPrice";
item1.SummaryType = DevExpress.Data.SummaryItemType.Sum;
item1.DisplayFormat = "Total {0:c2}";
item1.ShowInGroupColumnFooter = colUnitPrice;
gridView1.GroupSummary.Add(item1);
|
Visual Basic | 复制代码 |
---|
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Private gridView1.GroupFooterShowMode = GroupFooterShowMode.VisibleAlways
Private item As GridGroupSummaryItem = New GridGroupSummaryItem()
Private item.FieldName = "ProductName"
Private item.SummaryType = DevExpress.Data.SummaryItemType.Count
gridView1.GroupSummary.Add(item)
Dim item1 As GridGroupSummaryItem = New GridGroupSummaryItem()
item1.FieldName = "UnitPrice"
item1.SummaryType = DevExpress.Data.SummaryItemType.Sum
item1.DisplayFormat = "Total {0:c2}"
item1.ShowInGroupColumnFooter = colUnitPrice
gridView1.GroupSummary.Add(item1)
|