[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
    [Expand]Custom Painting
    [Collapse]Alpha Blending and Background Images
      Apply Alpha Blending Using Appearances
      Apply Alpha Blending Using Custom Painting
   [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)

Apply Alpha Blending Using Custom Painting

You can enhance a vertical grid's appearance using Alpha Blending technology. This involves assigning a background image to the vertical grid and painting the control elements using transparent pens and brushes. Please refer to the Alpha Blending Overview topic for details on this technology and a list of the ways in which it can be implemented. This particular topic deals with implementing Alpha Blending using custom painting.

Expanded Custom Painting and Alpha Blending

The vertical grids (VGridControl and PropertyGridControl) enable you to customize the appearance and content of their elements in any manner you like. This can be performed by manually painting the desired elements. To implement this, you must handle events specifically designed for this purpose. These events are listed in the Custom Painting Overview topic. Such events provide a number of parameters which can be used to obtain the Graphics object which represents the painting surface, the element's bounding rectangle and its style. Furthermore, each custom painting event has a Handled parameter that specifies whether default painting needs to be performed after the event handler has executed. Thus, you can use the events mentioned to implement the alpha blending feature in one of the following ways:

  • Paint the processed control element using transparent brushes and/or pens and set the Handled parameter to true. This technique is most used if you want to change the appearance of elements to achieve a result that is impossible when only using styles. The example below shows how to implement handling of custom paint events.
  • Change the element's appearance in the event handler so that colors are transparent. In this case, you must set the Handled parameter to false so that the element is painted in its default manner using the newly specified style. This technique is most used if you want to provide different appearances for elements of the same type. For instance, you cannot specify different styles for different row headers using view styles. So in this case you would need to handle the custom painting events and modify styles with respect to the currently processed row header. Please refer to the Specifying Styles Using Custom Painting Events topic for an example of using this technique.

Expanded Custom Painting Transparent Row Headers

The following sample code handles the VGridControlBase.CustomDrawRowHeaderCell event to paint row headers in a custom manner. The event handler paints a frame around the processed row header using the linear gradient transparent brush. The inner area is filled with the reversed brush then the caption string is painted within the inner area. Note that it is assumed that a background image is already assigned to the control using its BackgroundImage property.

The steps that are performed when painting the header cell are illustrated in the image below:

The result is shown in the image below.

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