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.v24.2.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.TreeList
#Declaration
[DXCategory("CustomDraw")]
public event CustomDrawNodeImagesEventHandler CustomDrawNodeImages
#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 Custom |
Bounds |
Gets the painted element’s bounding rectangle.
Inherited from Custom |
Cache |
Gets an object specifying the storage for the most used pens, fonts and brushes.
Inherited from Custom |
Graphics |
Gets an object used to paint.
Inherited from Custom |
Handled |
Gets or sets a value specifying whether an event was handled and that the default element painting is therefore not required.
Inherited from Custom |
Is |
Gets a value indicating whether the Tree |
Object |
Gets an object containing information about the painted element.
Inherited from Custom |
Painter |
Gets the painter object that provides the default element’s painting mechanism.
Inherited from Custom |
Select |
Gets or sets the index of the image displayed within the painted node when it is focused. |
Select |
Gets the location of the select image’s top-left corner. |
Select |
Gets the bounding rectangle of the select image. |
State |
Gets or sets the index of the state image displayed within the node. |
State |
Gets the location of the state image’s top-left corner. |
State |
Gets the bounding rectangle of the state image. |
The event data class exposes the following methods:
Method | Description |
---|---|
Default |
Performs default painting of an element.
Inherited from Custom |
Draw |
Paints the required HTML template inside an element that raised this event. The context parameter allows you to assign an object that transfers mouse events to template elements.
Inherited from Custom |
Draw |
Paints the required HTML template inside an element that raised this event.
Inherited from Custom |
#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.
#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.
Note
The Custom
event does not occur if a node does not display the imageTree
.
The WXI skin activates the In
(Tree
#Custom Draw Event for In-Cell Images
The RowImagesShowMode property allows you to choose the location of node images. If a Tree List draws its node images inside cells and a cell has no image to display, the control does not allocate space for this image and the CustomDrawNodeImages
event is never raised.
#Example
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.