Skip to main content

TreeList.CustomDrawEmptyArea Event

Enables you to custom paint a Tree List’s empty area.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v23.2.dll

NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.TreeList

Declaration

[DXCategory("CustomDraw")]
public event CustomDrawEmptyAreaEventHandler CustomDrawEmptyArea

Event Data

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

Property Description
Appearance Gets the painted element’s appearance settings. Inherited from CustomDrawEventArgs.
BehindColumn Gets the blank column’s bounding rectangle.
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.
EmptyAreaRegion Gets the region which is occupied by the empty area.
EmptyRectangles Gets the array of rectangles that specify the empty area.
EmptyRows Gets the bounding rectangle occupied by the empty rows.
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.

The event data class exposes the following methods:

Method Description
DefaultDraw() Performs default painting of an element. Inherited from CustomDrawEventArgs.
DrawHtml(HtmlTemplate, DxHtmlPainterContext, Action<DxHtmlPainterArgs>) 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 CustomDrawEventArgs.
DrawHtml(HtmlTemplate, Action<DxHtmlPainterArgs>) Paints the required HTML template inside an element that raised this event. Inherited from CustomDrawEventArgs.

Remarks

Handle the CustomDrawEmptyArea event to custom paint the control’s empty area(the area where Tree List nodes are going to be displayed).

See the Custom Draw Scenarios topic for information on using custom draw events.

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.

Example

The following code handles the TreeList.CustomDrawEmptyArea event to manually paint the control’s empty area when no nodes are displayed.

The image below shows the result.

TreeList-CustomDrawEmptyArea

using DevExpress.XtraTreeList;

private void treeList1_CustomDrawEmptyArea(object sender, CustomDrawEmptyAreaEventArgs e) {
    if (treeList1.Nodes.Count > 1) return;
    string s = "No Records Available";
    e.Appearance.FontStyleDelta = FontStyle.Bold;
    e.Appearance.FontSizeDelta = 2;
    e.Cache.DrawString(s, e.Appearance.Font, e.Cache.GetSolidBrush(Color.Black), e.Bounds);
    e.Handled = true;
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomDrawEmptyArea event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also