Description:
I wish to show several summary values under the same column. How can I do this?
Answer:
NOTE
Starting with version 11.1, GridView supports multiple total summaries in the same view footer cell by default.
This feature can be implemented by using the grid's owner draw abilities. i.e. you should set the View's FooterPanelHeight property to a value that makes it possible to paint two summary items. Then, handle the CustomDrawFooterCell event to paint summary values:
C#private void Form1_Load(object sender, System.EventArgs e)
{
//...
gridView1.Columns.AddField("Dummy");
gridView1.Columns["Dummy"].UnboundType = DevExpress.Data.UnboundColumnType.Integer;
GridSummaryItem si = new GridSummaryItem(DevExpress.Data.SummaryItemType.Average, "CategoryID", "");
gridView1.Columns["Dummy"].SummaryItem.Assign(si);
gridView1.Columns["Dummy"].Visible = false;
//...
}
private void gridView1_CustomDrawFooterCell(object sender, DevExpress.XtraGrid.Views.Grid.FooterCellCustomDrawEventArgs e) {
if(e.Column == colCategoryID) {
e.Painter.DrawObject(e.Info);
Rectangle r = e.Info.Bounds;
string text = e.Info.DisplayText;
e.Info.Bounds = new Rectangle(e.Info.Bounds.Left, e.Info.Bounds.Bottom + 1, e.Info.Bounds.Width, e.Info.Bounds.Height);
e.Info.DisplayText = view.Columns["Dummy"].SummaryText;
e.Painter.DrawObject(e.Info);
e.Handled = true;
e.Info.Bounds = r;
e.Info.DisplayText = text;
}
else
if (e.Column == colCategoryName)
e.Handled = true;
}
The sample project attached shows this approach in action.
See also: How to show multiple group summary values in the same group footer cell