Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [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]Getting Started
   [Expand]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Summaries
   [Expand]Data Editing
   [Expand]Filtering and Locating Rows
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Collapse]Appearance and Conditional Formatting
    [Expand]Look and Feel
    [Expand]Appearances
    [Expand]Conditional Formats
    [Collapse]Custom Painting
      Custom Painting Basics
      Tutorial: Custom Drawing
      Custom Painting Scenarios
      Elements that Can Be Custom Painted
      Manually Invalidating Controls
    [Expand]Alpha Blending and Background Images
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

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.

Expanded Online Video

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

Expanded More Videos

Expanded Custom Painting Basics

Custom draw events allow you to do the following.

  • Paint control elements manually.

    This enables you to provide any appearance you like for control elements. For instance, in the image below, the custom sort glyphs and filter buttons are painted within column headers.
  • Invoke the default painting mechanism of an element.

    It is possible to modify specific view information (e.g., display text) before invoking the default painting mechanism. The default painting method will automatically apply the changes made.

The image below shows a custom painted Grid View.

 

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 event handlers provide the Info parameter, which contains view settings specific to the painted element (display text, bounds, etc.). For instance, you can modify the Info parameter as required, and then invoke the default painting mechanism, which will render the element as specified by the Info parameter. The Info parameter is available when the following elements are painted: filter panel, band and column headers, view footer, group footer, group rows, preview section, row indicator and footer cells.

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.

Note

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.

Expanded See Also

How would you rate this topic?​​​​​​​