Skip to main content
A newer version of this page is available. .

How to: Custom Draw Footer Cells

Online Video

WinForms Grid - How to Custom Draw Footer Cells.

Example

The example shows how you can perform custom painting of footer cells with the GridView.CustomDrawFooterCell event.

CustomDrawFooterCell

using DevExpress.XtraGrid.Views.Grid;
using DevExpress.Utils.Drawing;

private void gridView1_CustomDrawFooterCell(object sender, FooterCellCustomDrawEventArgs e) {
    int dx = e.Bounds.Height;
    Brush brush = e.Cache.GetGradientBrush(e.Bounds, Color.Wheat, Color.FloralWhite,
      LinearGradientMode.Vertical);
    Rectangle r = e.Bounds;
    //Draw a 3D border
    BorderPainter painter = BorderHelper.GetPainter(DevExpress.XtraEditors.Controls.BorderStyles.Style3D);
    AppearanceObject borderAppearance = new AppearanceObject(e.Appearance);
    borderAppearance.BorderColor = Color.DarkGray;
    painter.DrawObject(new BorderObjectInfoArgs(e.Cache, borderAppearance, r));
    //Fill the inner region of the cell
    r.Inflate(-1, -1);
    e.Cache.FillRectangle(brush, r);
    //Draw a summary value
    r.Inflate(-2, 0);
    e.Appearance.DrawString(e.Cache, e.Info.DisplayText, r);
    //Prevent default drawing of the cell
    e.Handled = true;
}