dev GridView 的组计和分组计
/// <summary> /// //添加组计 /// </summary> private void SetGroupSummary(GridView gv, string fieldName, GridColumn showInColumn, string displayFormat) { gv.GroupSummary.Add(DevExpress.Data.SummaryItemType.Sum, fieldName, showInColumn, displayFormat);//添加组计 } /// <summary> /// 分组合计 /// </summary> private void SetGridGroup(GridView gv, string fieldName, string displayFormat, bool isCount = true) { GridGroupSummaryItem item = new GridGroupSummaryItem(); item.FieldName = fieldName; item.DisplayFormat = displayFormat; if (isCount) item.SummaryType = DevExpress.Data.SummaryItemType.Count; else item.SummaryType = DevExpress.Data.SummaryItemType.Sum; gv.GroupSummary.Add(item); }
调用
SetGridGroup(gridView2, "names", "总计:{0}"); SetGridGroup(gridView2, "iitem", "问题件合计:{0}", false); SetGroupSummary(gridView2, "iitem", gridColumn6, "组计:{0}");//添加组计