[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Get Started With Data Grid and Views
   [Expand]Data Binding
    Unbound Columns
   [Expand]Data Editing and Validation
   [Expand]Filter and Search
   [Expand]Focus and Selection Handling
    Format Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Collapse]Appearance and Conditional Formatting
    [Collapse]Custom Painting
      Custom Painting Basics
      Custom Painting Scenarios
      Elements that Can Be Custom Painted
      Manually Invalidating Controls
    [Expand]Alpha Blending and Background Images
    Split Presentation
    Row Preview Sections
   [Expand]Batch Modifications
    Hit Information
    Popup Menus
   [Expand]Save and Restore Layout
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Custom Painting Scenarios

Custom draw events provide complete control over the appearance of grid elements. This document provides examples illustrating common scenarios for custom draw events. For basic information on custom painting in Grid Control, refer to the Custom Painting Basics topic.


Custom painting and alpha blending features are not applied to the print and export versions of the Grid Control.


In specific paint themes (e.g., skins and Office2003), you are not able to change the background of some elements. Changing the background of these elements via the Appearance parameter of custom draw events is also not supported.

There are three main scenarios for custom draw event usage.


Expanded Manual Element Rendering

Custom draw events allow you to manually render grid elements using the methods provided by the event's CustomDrawEventArgs.Cache and CustomDrawEventArgs.Appearance objects. These objects' methods allow you to draw various graphics primitives (lines, rectangles, ellipses, images, etc.). When performing manual element rendering, you typically need to set the event's CustomDrawEventArgs.Handled parameter to true. Otherwise, the default painting mechanism will be invoked after event execution, and it will override your rendering.


The following example demonstrates how to use the GridView.CustomDrawCell event to custom paint the RequiredDate column's cells. If a cell refers to the current or following date, its background is filled with a gradient brush. If the cell contains a date that is greater than the current date, the cell will display the number of days left until the specified date. The appearance of the other cells is not affected.

Expanded Combining Default Painting and Custom Painting

The following scenario allows you to paint custom information over the default rendering. To accomplish this task, first invoke the default painting mechanism for an element using the CustomDrawEventArgs.DefaultDraw method. Then, you can paint additional information over the default rendering using the methods of the event's CustomDrawEventArgs.Graphics and CustomDrawEventArgs.Appearance properties.

Before invoking the default painting mechanism, you can modify an element's display information. The default rendering mechanism, when invoked, will apply these changes. For instance, you can modify the appearance of an element using the event's CustomDrawEventArgs.Appearance property. Custom draw events for some elements (Filter Panel, band and column headers, View Footer, Group Footer, group rows, Preview Section, row indicator and footer cells) provide the Info parameter, which contains element-specific view information. For these events, you can change the Info object's properties to customize an element's display text or change the boundaries of inner elements. If an event contains a DisplayText property, you can set it to a custom value before invoking the default rendering.

A call to the CustomDrawEventArgs.DefaultDraw method automatically sets the event's Handled parameter to true. This prevents the default painting mechanism from being re-invoked after event execution.

Note that modifying the boundaries of elements or inner elements changes the View layout. If you need to change the boundaries of elements for the purpose of custom painting, you should restore the boundaries immediately after the default painting mechanism is invoked.


In the sample below, the GridView.CustomDrawCell event is handled to custom-paint data cells.

The CustomDrawEventArgs.DefaultDraw method applies the default draw to all cells. For all "Units in Stock" cells that display 0, a custom icon is drawn on top of this default cell rendering.

Expanded Customizing Element Display Information for Default Rendering

When handling a custom draw event, you can change an element's view information (e.g., appearance or content) and set the event's CustomDrawEventArgs.Handled property to false (the default value). In this case, the default rendering will automatically be invoked after the event execution. The painting mechanism will use the modified view information to render the element.

The following table describes custom draw events that allow you to customize an element's display information.

Custom draw event

Allows you to ...












  • Change the display information via the event's Info parameter.

    The Info object allows you to change the display text (if it is available for the element being painted).

    Avoid changing the boundaries of the inner elements as this may corrupt the View's layout.

  • Provide a custom appearance using the event's Appearance property.








  • Dynamically supply custom display text via the DisplayText/CardCaption parameter.
  • Provide a custom appearance using the event's Appearance property.


The following example demonstrates how to specify a custom background for footer cells using the GridView.CustomDrawFooterCell event. The default appearance settings specified by the View's GridViewAppearances.FooterPanel property will be ignored.

The image below shows the result.

Expanded See Also

Is this topic helpful?​​​​​​​