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
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Collapse]Tree List
   [Expand]Product Information
   [Collapse]Feature Center
    [Expand]Data Binding
    [Expand]Nodes
    [Expand]Data Editing
    [Expand]Data Representation
    [Expand]Sorting
    [Expand]Filtering
    [Expand]Summaries
    [Collapse]Appearances and Look And Feel
     [Expand]Alpha Blending
     [Expand]Appearances
     [Collapse]Custom Drawing
       Custom Draw Scenarios
       List of Custom Draw Events
       Manual Invalidation
       Painters
      Skins and LookAndFeel
    [Expand]Focus, Selection and Navigation
     Formatting Cell Values
    [Expand]Miscellaneous
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End User Capabilities
   [Expand]Member Tables
  [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]ASP.NET Core 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]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Custom Draw Scenarios

Custom draw events provide complete control over the appearance of the control's elements. This document covers the main scenarios for custom draw event usage.

Note

Custom draw events do not allow you to change the appearance of a printed/exported version of the Tree List.

The TreeList's custom draw events can be handled to implement the following scenarios.

  • Manual Element Rendering

    Custom draw events allow you to manually render Tree List elements using the methods provided by the event's CustomDrawEventArgs.Graphics and CustomDrawEventArgs.Appearance objects. These objects' methods allow you to draw various graphics primitives (lines, rectangles, ellipses, images, etc.).

    When performing manual element rendering, you typically need to set the event's CustomDrawEventArgs.Handled parameter to true. Otherwise, the default painting mechanism will be invoked after event execution, and it will override your rendering.

  • Combining Default Painting and Custom Painting

    This approach allows you to paint custom information over the default rendering. To accomplish this task, first invoke the default painting mechanism for an element using the CustomDrawEventArgs.DefaultDraw method. Then, you can paint additional information over the default rendering using the methods of the event's CustomDrawEventArgs.Graphics and CustomDrawEventArgs.Appearance properties.

    Before invoking the default painting mechanism, you can modify an element's display information (content, bounds and appearance settings) via the event's parameters. The default rendering mechanism, when invoked, will apply these changes.

    A call to the CustomDrawEventArgs.DefaultDraw method automatically sets the event's Handled parameter to true. This prevents the default painting mechanism from being re-invoked after event execution.

    Note that modifying the boundaries of elements or inner elements changes the Tree List layout. If you need to change the boundaries of elements for the purpose of custom painting, you should restore the boundaries immediately after the default painting mechanism is invoked.

  • Customizing Element Display Information for Default Rendering

    When handling a custom draw event, you can change an element's view information (e.g., appearance or content) and set the event's CustomDrawEventArgs.Handled property to false (the default value). In this case, the default rendering will automatically be invoked after event execution. The painting mechanism will use the modified view information to render the element.

Note

In specific paint themes (e.g., skins and Office2003), you are not able to change the background of some elements. Changing the background of these elements via the Appearance parameter of custom draw events is also not supported.

Expanded Example

The following example custom paints column headers, summary footer, footer cells and indicator cells via the TreeList.CustomDrawColumnHeader, TreeList.CustomDrawFooter, TreeList.CustomDrawFooterCell and TreeList.CustomDrawNodeIndicator events.

Three functions are declared that implement custom painting. These are used to draw the background of the raised and sunken elements, and to paint the text with the predefined alignment within elements.

The image below shows the result.

Expanded See Also

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