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

GridView.CustomDrawFooterCell Event

Enables you to paint view footer cells manually.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v18.1.dll

Declaration

[DXCategory("CustomDraw")]
public event FooterCellCustomDrawEventHandler CustomDrawFooterCell

Event Data

The CustomDrawFooterCell event's data class is FooterCellCustomDrawEventArgs. The following properties provide information specific to this event:

Property Description
Appearance Gets the painted element’s appearance settings. Inherited from CustomDrawEventArgs.
Bounds Returns a value specifying limits for the drawing area. Inherited from CustomDrawEventArgs.
Cache Provides methods to paint on drawing surfaces in GDI+ and DirectX modes. See DirectX hardware acceleration to learn more. Inherited from CustomDrawEventArgs.
Column Gets the column containing the painted element. Inherited from RowCellObjectCustomDrawEventArgs.
Graphics A GDI+ drawing surface. Use the CustomDrawEventArgs.Cache property instead if you enable the DirectX hardware acceleration. Inherited from CustomDrawEventArgs.
Handled Gets or sets a value specifying whether an event was handled and that the default element painting is therefore not required. Inherited from CustomDrawEventArgs.
Info Gets an object providing information necessary to paint a footer cell.
Painter Gets the painter object that provides the default element painting mechanism. Inherited from CustomDrawObjectEventArgs.
RowHandle Gets the handle of the row whose corresponding element is being painted. Inherited from RowObjectCustomDrawEventArgs.

The event data class exposes the following methods:

Method Description
DefaultDraw() Performs default painting of an element. Inherited from CustomDrawEventArgs.

Remarks

The CustomDrawFooterCell event fires each time a view footer cell needs to be repainted. The footer cell’s column is identified by the RowCellObjectCustomDrawEventArgs.Column parameter. See the Custom Painting Basics and Custom Painting Scenarios topics for information on using custom draw events.

Note

You can change the background color of footer cells via the CustomDrawEventArgs.Appearance parameter in the following paint styles: Flat, WindowsXP, Style3D, UltraFlat, MixedXP and Web. Use the BaseView.PaintStyleName property to change the paint style.

Note

The control’s events designed to change the appearance or rendering of control elements must not be used to update cell values or to modify the control’s layout. Any inappropriate operation which causes a layout update, may break the normal control behavior.

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;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the CustomDrawFooterCell event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also