[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
  [Expand]Data Grid
  [Collapse]Vertical Grid
   [Expand]Binding to Data
   [Expand]Data Layout: Records, Rows and Cells
   [Expand]Data Editing and Validation
    Formatting Values
   [Expand]Drag and Drop
   [Collapse]Appearance and Custom Painting
    [Collapse]Custom Painting
      Elements that can be Custom Painted
      Custom Painting Samples
    [Expand]Alpha Blending and Background Images
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Hit Information
    Batch Modifications
   [Expand]Member Tables
  [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

All DevExpress .NET Windows Forms controls use Appearances (the AppearanceObject objects) to customize their look and feel. The vertical grid controls (VGridControl and PropertyGridControl) provide both design time and runtime facilities for customizing the appearance of their visual elements. This implies modifying attributes such as the background and foreground colors, background images, font settings, etc. The appearance settings used to paint the grid's elements can be customized in a number of ways which are listed in the Appearance and Conditional Formatting document.

If the appearance customization techniques provided don't suit your needs, you can handle the custom draw events.


You can paint elements manually by handling vertical grid events, specifically designed for this purpose. Each event is used to paint the elements of a specific type and fires before an individual element is painted. For instance, the VGridControlBase.CustomDrawTreeButton event can be used to paint tree buttons displayed within the headers of parent rows. It fires for each individual tree button every time the button needs to be painted (e.g. when the row becomes visible or when it is expanded or collapsed). Thus, you can provide a custom appearance for all types of elements in all their states.

The image below shows an example of using the custom painting feature.

The custom draw events can be handled for the following purposes:

  • To paint the elements manually.

    This allows you to provide any appearance you like for grid elements.

  • To paint the elements using the default mechanism but with modified appearance settings.

    This can be useful when custom text needs to be displayed within data cells or different appearances provided for elements of the same type (row headers, data cells, etc.).

Custom draw events are raised before the grid elements are painted. These events have different sets of parameters since they are designed to paint different elements. However, some parameters are common to all events. These parameters are listed below.

Parameter Description
CustomDrawEventArgs.Graphics Gets the System.Drawing.Graphics object which represents the painting surface. This object provides a number of methods that can be used to paint text, images and geometrical primitives (such as rectangles, circles, polylines, etc). Use these methods to paint the processed element's content in the manner you want.
CustomDrawEventArgs.Bounds Gets the bounding rectangle of the element being painted. Use this parameter to determine where to paint.
CustomDrawEventArgs.Cache Gets an object which specifies the storage for the most used pens, fonts and brushes.
CustomDrawEventArgs.Handled Specifies whether the event is handled. If custom drawing is implemented and the Handled property's value is set to false, all the custom drawing performed will be overwritten by the default painting mechanism using the appearance settings. Set this property to true to prevent the default painting mechanism from clearing any custom drawing.
CustomDrawEventArgs.Appearance Gets the appearance settings used to paint an element.

See the following documents for a list of the elements that can be custom painted and examples:

Expanded See Also

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