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
  [Expand]Data Grid
  [Collapse]Vertical Grid
   [Expand]Overview
   [Expand]Fundamentals
   [Collapse]Concepts
    [Expand]Layouts
    [Expand]Binding to Data
    [Expand]Rows
    [Expand]Records
    [Expand]Cells
    [Expand]In-place Editors
     Formatting
    [Expand]Appearances
     Hit Information
    [Expand]Custom Painting
    [Collapse]Alpha Blending and Background Images
      Apply Alpha Blending Using Appearances
      Apply Alpha Blending Using Custom Painting
    [Expand]Customization Form
     Batch Modifications
    [Expand]Drag and Drop
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
   [Expand]Member Tables
  [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

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.

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