Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Custom Paint Group Footers

The example shows how you can customize group footers and their cells by handling the GridView.CustomDrawRowFooter and GridView.CustomDrawRowFooterCell events.

CustomDraw - GroupRowFooter

gridView1.OptionsView.GroupFooterShowMode = GroupFooterShowMode.VisibleAlways;
gridView1.CustomDrawRowFooter += (sender, e) =>
{
    e.Cache.FillRectangle(e.Cache.GetGradientBrush(e.Bounds, Color.Red, Color.Maroon, System.Drawing.Drawing2D.LinearGradientMode.Horizontal), e.Bounds);
    //Prevent default painting
    e.Handled = true;
};

GridGroupSummaryItem item = new GridGroupSummaryItem() {
    FieldName = "MPG Highway",
    SummaryType = DevExpress.Data.SummaryItemType.Sum,
    ShowInGroupColumnFooter = gridView1.Columns["MPG Highway"]
};
gridView1.GroupSummary.Add(item);
gridView1.CustomDrawRowFooterCell += (sender, e) =>
{
    e.Bounds.Inflate(-5, -5);
    e.Appearance.ForeColor = Color.Teal;
    e.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
    e.Appearance.FontSizeDelta = 3;
    e.DefaultDraw();
    e.Cache.DrawRectangle(e.Cache.GetPen(Color.DarkOliveGreen, 5), e.Bounds);
    e.Handled = true;
};