Back to Devexpress

TreeList.GetPreviewText Event

windowsforms-devexpress-dot-xtratreelist-dot-treelist-41cd22dd.md

latest3.5 KB
Original Source

TreeList.GetPreviewText Event

Enables you to supply custom text for nodes’ preview sections.

Namespace : DevExpress.XtraTreeList

Assembly : DevExpress.XtraTreeList.v25.2.dll

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

Declaration

csharp
public event GetPreviewTextEventHandler GetPreviewText
vb
Public Event GetPreviewText As GetPreviewTextEventHandler

Event Data

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

PropertyDescription
NodeGets the current Tree List node. Inherited from NodeEventArgs.
PreviewTextGets or sets the preview text.

Remarks

To display custom text in preview sections, set the TreeListOptionsView.ShowPreview option to true and handle the GetPreviewText event. The GetPreviewText event fires repeatedly for each node. To supply custom text, assign it to the GetPreviewTextEventArgs.PreviewText event parameter.

Example

The sample code below handles the TreeList.GetPreviewText event to display the Location and Phone field values in preview sections.

The following image shows the results.

csharp
using DevExpress.XtraTreeList;

treeList1.OptionsView.ShowPreview = true;

private void treeList1_GetPreviewText(object sender, GetPreviewTextEventArgs e) {
   e.PreviewText = "Office Location: " + e.Node["Location"].ToString() + "; Phone: " + 
     e.Node["Phone"].ToString();
}
vb
Imports DevExpress.XtraTreeList

treeList1.OptionsView.ShowPreview = True

Private Sub TreeList1_GetPreviewText(ByVal sender As Object, _
ByVal e As GetPreviewTextEventArgs) Handles TreeList1.GetPreviewText
   e.PreviewText = "Office Location: " + e.Node("Location") + "; Phone: " + e.Node("Phone")
End Sub

See Also

PreviewFieldName

PreviewLineCount

ShowPreview

AutoCalcPreviewLineCount

TreeList Class

TreeList Members

DevExpress.XtraTreeList Namespace