Custom Painting Basics

Like other DevExpress .NET WinForms controls, the GridControl supports the Appearances mechanism, to customize the look and feel of its elements. It allows you to modify attributes such as background and foreground colors, background images, font settings, etc.
If you need more control over element rendering, consider using the custom draw events provided by the GridControl, for each visual element it contains.

Note

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

Online Video

Learn how to custom draw row cells and column headers using dedicated events.

Custom draw events are raised before grid elements are painted. Each custom draw event handler receives a CustomDrawEventArgs descendant as a parameter. This object's properties specify the bounds of an element, the graphic surface, the appearance settings and various view information related to the painted element.

Custom draw event handlers provide the CustomDrawEventArgs.DefaultDraw method, which allows you to invoke the default painting mechanism of an element during event execution.
There is also another implicit way to invoke the default painting mechanism. If the event's CustomDrawEventArgs.Handled parameter is set to false (the default value), the default painting mechanism will automatically be invoked after your custom draw event handler is completed.
Note that the default painting mechanism overrides all rendering you may have performed before. The DefaultDraw method automatically sets the Handled parameter to true, to prevent the default painting mechanism from being invoked again after event execution.
However, if you paint an element manually and do not use the DefaultDraw method, you should manually set the Handled parameter to true.

Some custom draw events provide properties that specify an element's display text. You can modify these properties and then invoke the default painting mechanism.
For instance, the GridView.CustomDrawCell event provides the DisplayText property, and the CardView.CustomDrawCardCaption event provides the CardCaption property, which can be modified before the default rendering.

See the following documents for information on custom drawing approaches and a list of elements that can be custom painted.

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