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
    [Collapse]Custom Painting
      Elements that can be Custom Painted
      Custom Painting Samples
    [Expand]Alpha Blending and Background Images
    [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

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 Appearances Overview document.

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

Expanded CUSTOM PAINTING BASICS

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

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