TreeList.CustomDrawNodePreview Event
Allows you to custom paint preview sections.
Namespace: DevExpress.XtraTreeList
Assembly: DevExpress.XtraTreeList.v18.2.dll
Declaration
[DXCategory("CustomDraw")]
public event CustomDrawNodePreviewEventHandler CustomDrawNodePreview
Event Data
The CustomDrawNodePreview event's data class is CustomDrawNodePreviewEventArgs. 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. |
PreviewText | Gets or sets the painted preview section’s text. |
The event data class exposes the following methods:
Method | Description |
---|---|
DefaultDraw() | Performs default painting of an element. Inherited from CustomDrawEventArgs. |
Remarks
See the Custom Draw Scenarios topic for information on using custom draw events.
Important
Never change cell values or modify the control’s layout on this event, or any other event designed to tune the control’s appearance. Any action that causes a layout update can cause the control to malfunction.
Example
The following sample code handles the TreeList.CustomDrawNodePreview
event. It is used to perform custom painting of preview sections.
The image below displays the result of sample code execution.
using System.Drawing;
using System.Drawing.Drawing2D;
using DevExpress.XtraTreeList
private void treeList1_CustomDrawNodePreview(object sender, CustomDrawNodePreviewEventArgs e) {
// filling background with a linear gradient brush
Brush backBrush = e.Cache.GetGradientBrush(e.Bounds, Color.LightGoldenrodYellow, Color.Cornsilk, LinearGradientMode.Vertical);
e.Cache.FillRectangle(backBrush, e.Bounds);
// painting the preview string
e.Appearance.FontStyleDelta = FontStyle.Italic;
e.Cache.DrawString(e.PreviewText, e.Appearance.Font, Brushes.Maroon, e.Bounds, e.Appearance.GetStringFormat());
// prohibiting default painting
e.Handled = true;
}