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 Samples

The elements in the vertical grids (VGridControl and PropertyGridControl) can be manually painted by handling custom draw events. This topic provides examples which demonstrate how to use these events. For general information on custom painting, see the Custom Painting Overview topic. Elements that can be custom painted are listed in the Elements that can be Custom Painted topic.

There are two main scenarios for which custom draw events are normally used:

  • To paint elements in their entirety using the drawing methods of the Graphics object.
  • The information (appearance, contents, bounds) used to draw an element can be modified . This forces the control to paint the element in the default manner but with modified settings.

The subsections below provide examples for each of these cases.

Expanded Manual Painting

As mentioned above, the vertical grid's elements can be painted manually without invoking the default painting mechanism. The event parameter's CustomDrawEventArgs.Graphics property represents the graphic surface and this provides the drawing methods which you can use to render the grid's element. To prevent the element's default painting from being performed set the CustomDrawEventArgs.Handled property to true. This indicates that the event was handled and that no default actions are required. If this property is set to false, the element will be painted using the default drawing mechanism after your event handler has been executed.

The following sample code shows how to handle the VGridControlBase.CustomDrawTreeButton event to custom paint tree buttons. In this example, custom painting is not applied to category expand buttons and they are painted in the default manner. The result is shown in the image below:

The next example demonstrates how to draw the currently focused cell. The VGridControlBase.CustomDrawRowValueCell event is handled for this purpose.

The image below shows the result:

Expanded Customizing the Display Information of Elements

A vertical grid's elements can be painted using the default mechanism but with modified settings such as their appearance, display text, image, etc. When handling the custom draw events, you must leave the event parameter's CustomDrawEventArgs.Handled property set to false. This forces the grid to paint an element in its default manner but with modified settings.

The following example shows how to supply custom appearances to multi-editor row header cells. The VGridControlBase.CustomDrawRowHeaderCell event is handled to apply custom appearance settings to the row header cells of the "Phones" column. The VGridControlBase.CustomDrawRowHeaderIndent event is handled to paint the "Phones" row's indent with the appearance settings used to paint the first row header cell. The result is shown in the image below:

Expanded See Also

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