TreeList.CustomDrawEmptyArea Event

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

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v20.1.dll

Declaration

[DXCategory("CustomDraw")]
public event CustomDrawEmptyAreaEventHandler CustomDrawEmptyArea
<DXCategory("CustomDraw")>
Public Event CustomDrawEmptyArea As CustomDrawEmptyAreaEventHandler

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.

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.

Examples

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;
}
See Also