C# Dev GridView自定义底部统计单元格

效果图

Id列和UserId列的总和数据在底部单元格中


实现:

第一步 添加一个GridControl,设置“在父容器中停靠”,设置数据源

第二步:打开Run Designer设置字段的SummaryItem的SummaryType为Sum


第三步:设置GridView的OptionView的ShowFooter=true


第四步:自定义单元格样式


[csharp] view plain copy
  1. private void gridView1_CustomDrawFooterCell(object sender, DevExpress.XtraGrid.Views.Grid.FooterCellCustomDrawEventArgs e)  
  2.        {  
  3.            int dx = e.Bounds.Height;  
  4.            Brush brush = e.Cache.GetGradientBrush(e.Bounds, Color.Wheat, Color.FloralWhite, LinearGradientMode.Vertical);  
  5.            Rectangle r = e.Bounds;  
  6.            ControlPaint.DrawBorder3D(e.Graphics, r, Border3DStyle.RaisedInner);  
  7.            r.Inflate(-1, -1);  
  8.            e.Graphics.FillRectangle(brush, r);  
  9.            r.Inflate(-2, 0);  
  10.            e.Appearance.DrawString(e.Cache, e.Info.DisplayText, r);  
  11.            e.Handled = true;  
  12.        }  
转载于:https://blog.csdn.net/u011176794/article/details/79847522