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

Painters

The Tree List control's elements can be custom painted. This can be done by using either the custom draw events designed for this purpose, or by providing your own Painter class for the control. This section contains information on creating a custom Painter class.

Expanded Tree List Painters

Tree List painters are objects implementing the ITreeListPaintHelper interface (the following section describes this interface). To create a custom painter, you need to create a class that implements the ITreeListPaintHelper interface. Alternatively, you can create a custom painter class, deriving it from the TreeList's default painter - the DevExpress.XtraTreeList.Painter.TreeListPaintHelper class

To use a custom painter, assign an instance of this class to the DefaultPainter property of the TreeList.Painter object. This property refers to an instance of the painter class that is used to paint the TreeList's elements. Initially, this property refers to a TreeListPaintHelper object.

Expanded ITreeListPaintHelper Interface

Tree List paint helpers must support the ITreeListPaintHelper interface. This interface declares methods that paint particular types of elements. The code below is the declaration of this interface.

public interface ITreeListPaintHelper {
   void DrawOpenCloseButton(CustomDrawNodeButtonEventArgs e);
   void DrawColumn(CustomDrawColumnHeaderEventArgs e);
   void DrawNodePreview(CustomDrawNodePreviewEventArgs e);
   void DrawNodeSelectImage(CustomDrawNodeImagesEventArgs e);
   void DrawNodeStateImage(CustomDrawNodeImagesEventArgs e);
   void DrawIndicator(CustomDrawNodeIndicatorEventArgs e);
   void DrawFooterBackGround(CustomDrawEventArgs e);
   void DrawRowFooterCell(CustomDrawRowFooterCellEventArgs e);
   void DrawFooterCell(CustomDrawFooterCellEventArgs e);
   void DrawNodeCell(CustomDrawNodeCellEventArgs e);
}

The following table lists the methods of this interface, provides a brief description for each of them and lists the custom painting events that can be used instead.

Method Description CustomDraw Event
DrawOpenCloseButton Paints group buttons. Gets a CustomDrawNodeButtonEventArgs object as the parameter. TreeList.CustomDrawNodeButton
DrawColumn Paints elements of the column header panel. Gets a CustomDrawColumnHeaderEventArgs object as the parameter. TreeList.CustomDrawColumnHeader
DrawNodePreview Paints preview sections. Gets a CustomDrawNodePreviewEventArgs object as the parameter. TreeList.CustomDrawNodePreview
DrawNodeSelectImage Paints select images. Gets a CustomDrawNodeImagesEventArgs object as the parameter. TreeList.CustomDrawNodeImages
DrawNodeStateImage Paints state images. Gets a CustomDrawNodeImagesEventArgs object as the parameter. TreeList.CustomDrawNodeImages
DrawIndicator Paints the indicator cells. Gets a CustomDrawNodeIndicatorEventArgs object as the parameter. TreeList.CustomDrawNodeIndicator
DrawFooterBackGround Paints the summary footer's background. Gets a CustomDrawEventArgs object as the parameter. TreeList.CustomDrawFooter
DrawRowFooterCell Paints row footer cells. Gets a CustomDrawRowFooterCellEventArgs object as the parameter. TreeList.CustomDrawRowFooterCell
DrawFooterCell Paints summary footer cells. Gets a CustomDrawFooterCellEventArgs object as the parameter. TreeList.CustomDrawFooterCell
DrawNodeCell Paints the node cells. Gets a CustomDrawNodeCellEventArgs object as the parameter. TreeList.CustomDrawNodeCell

Expanded Example

The code below creates a simple paint helper, deriving it from the standard TreeListPaintHelper class. The DrawFooterBackGround method is overridden to custom paint the summary footer.

The image below shows the Tree List control before and after the code has been executed.

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