Devexpress分组小计
gridViewmachinerepair.Columns["machine"].Group();
#region 自定义计算 double dateCount = 0; gridViewmachinerepair.CustomSummaryCalculate += (sender, e) => { if (e.IsGroupSummary) { GridView view = sender as GridView; switch (e.SummaryProcess) { //calculation entry point case CustomSummaryProcess.Start: dateCount = 0; break; //consequent calculations case CustomSummaryProcess.Calculate: double values = Convert.ToDouble(view.GetRowCellValue(e.RowHandle, view.Columns["outqty"])); //DateTime current = DateTime.Now; System.Globalization.CultureInfo cul = System.Globalization.CultureInfo.CurrentCulture; dateCount += values; break; //final summary value case CustomSummaryProcess.Finalize: e.TotalValue = dateCount; break; } } }; gridViewmachinerepair.GroupSummary.Add(SummaryItemType.Custom, "outqty", gridViewmachinerepair.Columns["outqty"], "出库数量:{0}"); #endregion
![](https://img2020.cnblogs.com/blog/1288881/202105/1288881-20210520160914304-2075434764.png)
Working with Summaries in Code. Custom Summaries | WinForms Controls | DevExpress Documentation
第二种:
这样设置: