[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
      Style Schemes
      Customizing Appearances of Individual Rows
      Customizing Appearances of Individual Cells
      Specifying Styles Using Custom Painting Events
    [Expand]Custom Painting
    [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)

Specifying Styles Using Custom Painting Events

The custom painting events fire for each element when it needs to be painted. These events provide two opportunities. The first is to paint the element being processed manually, please refer to the Custom Painting Overview topic for details on how to implement this. The second is to change an element's appearance settings prior to it being painted. This topic describes how to perform this and for what purposes this can be used.

Expanded The Basics of Specifying Styles Using Custom Painting Events

The vertical grid controls (VGridControl and PropertyGridControl) provide a number of events that enable you to paint elements in a custom manner. Each event fires for elements of a specific type. Thus, the parameter sets of these events are not common since different information is required to paint different elements. However, some of the individual parameters are common. For instance, each custom painting event has parameters that specify the painted element's bounding rectangle, the Graphics object which represents the painting surface, etc. All events also have a common CustomDrawEventArgs.Appearance parameter, which lets you customize the appearance settings of the processed element.

Use the custom painting events to specify appearance settings only when it is necessary to assign them to individual elements of a certain type (when this cannot be performed by other means). For instance, you can use this technique to change a particular editor row's header style.

An example of using the custom painting events unnecessarily is to specify different styles for category rows. Because this can be performed using the rows' BaseRow.Appearance properties and using the custom painting events in this case would lead to a slight performance decrease.

Note: The custom painting events fire just prior to an element being painted. Thus, they have the highest priority so they override all other appearance settings.

Expanded Specifying Custom Styles for Row Headers - A Sample

The sample in this section shows how to change the appearance settings of an individual row headers. It handles the VGridControlBase.CustomDrawRowHeaderCell and VGridControlBase.CustomDrawRowHeaderIndent events to display headers of the Trademark and Model rows using a different style. The auxiliary InitAppearances method creates and customizes a custom appearance object which will be applied to the required elements. This method is called when the application starts. See the code below.

The image below displays the result of handling events in such a manner.

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