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}");//添加组计

 

posted @ 2019-01-10 13:07  世人皆萌  阅读(1404)  评论(0编辑  收藏  举报