[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'ComCtrls' (#lcl)

# TCustomTreeView.CustomDrawItem

Performs custom drawing for a tree node using the event handlers in the control.

## Declaration

Source position: comctrls.pp line 3573

`protected function TCustomTreeView.CustomDrawItem(`
`Node: TTreeNode;`
`State: TCustomDrawState;`
`Stage: TCustomDrawStage;`
`var PaintImages: Boolean`
`):Boolean; virtual;`

## Arguments

`Node` |  | Tree node drawn in the method.
`State` |  | State for the tree node (selected, focused, disabled, et. al.).
`Stage` |  | Drawing stage for the tree view item. cdPrePaint allows the OnCustomDrawItem event handler to be signalled.
`PaintImages` |  | True if images should be drawn in the OnAdvancedCustomDrawItem event handler.

## Function result

True if default drawing needs to be performed in the tree view control.

## Description

CustomDrawItem is a Boolean function used to perform custom drawing for the specified tree node using the event handlers for the control.

The OnCustomDrawItem and OnAdvancedCustomDrawItem event handlers are signalled to perform the custom drawing actions needed for the tree node. OnCustomDrawItem is signalled (when assigned) only when Stage contains the value cdPrePaint. OnCustomDrawItem is signalled (when assigned) for any of the values in the TCustomDrawStage enumeration.

State denotes one of Selected, Grayed, Disabled, Checked, Focused, Default, Hot, Marked or Indeterminate.

If PaintImages is True, images should be painted as well as text in the event handler routine.

The return value indicates whether default drawing for the tree node needs to be performed in the tree view control. True indicates that the control is responsible for default drawing, and the event handlers did not perform the action. False indicates that a handler routine performed default drawing, and it can be skipped in the tree view control.

CustomDrawItem is called from the DoPaintNode method. It occurs after StateImages, drawing state, and the display rectangle for the tree node has been determined.

See CustomDraw for the actions performed when drawing the entire tree view control.

## See also

TCustomTreeView.OnCustomDrawItem |  | Event handler signalled to custom draw an item (tree node) on the control.
TCustomTreeView.OnAdvancedCustomDrawItem |  | OnAdvancedCustomDrawItem - event handler for advanced custom drawing item.
TCustomTreeView.DoPaintNode |  | Renders the specified tree node to the canvas for the control.
TCustomTreeView.CustomDraw |  | Performs custom drawing using the assigned event handlers for the tree view control.
TCustomTreeView.OnCustomDraw |  | Event handler signalled to perform custom drawing for the tree view control.
TCustomTreeView.OnAdvancedCustomDraw |  | Event handler signalled to custom draw the grid control using drawing stages.
TTreeNode |  | Implements a tree node displayed in a TTreeView control.
TCustomDrawStage |  | TCustomDrawStage a series of constants to define the drawing stages for custom-drawn controls.
TCustomDrawState |  | TCustomDrawState - set of TCustomDrawStateFlag.