TreeList.CustomDrawNodeImages Event

Provides access to a GDI+/DirectX drawing surface and allows you to draw node icons manually.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll

Declaration

[DXCategory("CustomDraw")]
public event CustomDrawNodeImagesEventHandler CustomDrawNodeImages
<DXCategory("CustomDraw")>
Public Event CustomDrawNodeImages As CustomDrawNodeImagesEventHandler

Event Data

The CustomDrawNodeImages event's data class is CustomDrawNodeImagesEventArgs. The following properties provide information specific to this event:

Property Description
Appearance Gets the painted element's appearance settings. Inherited from CustomDrawEventArgs.
Bounds Gets the painted element's bounding rectangle. Inherited from CustomDrawEventArgs.
Cache Gets an object specifying the storage for the most used pens, fonts and brushes. Inherited from CustomDrawEventArgs.
Graphics Gets an object used to paint. Inherited from CustomDrawEventArgs.
Handled Gets or sets a value specifying whether an event was handled and that the default element painting is therefore not required. Inherited from CustomDrawEventArgs.
IsRightToLeft Gets a value indicating whether the TreeList's elements are aligned to support locales using right-to-left fonts. Inherited from CustomDrawEventArgs.
ObjectArgs Gets an object containing information about the painted element. Inherited from CustomDrawEventArgs.
Painter Gets the painter object that provides the default element's painting mechanism. Inherited from CustomDrawEventArgs.
SelectImageIndex Gets or sets the index of the image displayed within the painted node when it is focused.
SelectImageLocation Gets the location of the select image's top-left corner.
SelectRect Gets the bounding rectangle of the select image.
StateImageIndex Gets or sets the index of the state image displayed within the node.
StateImageLocation Gets the location of the state image's top-left corner.
StateRect Gets the bounding rectangle of the state image.

Remarks

Nodes can display the following icons:

  • Select Image - two icons that automatically switch when a node gets / loses the focus.
  • State Image - any custom icon.

veNodeImage

Draw Node Images

The TreeList.CustomDrawNodeImages event provides access to a GDI+/DirectX drawing surface and allows you to draw node icons manually.

See Custom Draw Scenarios for more information on how to use a drawing surface.

Examples

The code below shows how to fill the background with a custom color and then draw the image on top.

private void TreeList_CustomDrawNodeImages(object sender, CustomDrawNodeImagesEventArgs e) {
    if (e.Node.Focused)
        e.Cache.FillRectangle(e.Cache.GetSolidBrush(Color.Orange), e.StateRect);
    e.DefaultDraw();
}
IMPORTANT

Do not change cell values, modify the control's layout, or change the control's object model in the events used for custom control painting. Actions that update the layout can cause the control to malfunction.

See Also