Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TreeList.GetPreviewText Event

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

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v24.2.dll

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

#Declaration

public event GetPreviewTextEventHandler GetPreviewText

#Event Data

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

Property Description
Node Gets the current Tree List node. Inherited from NodeEventArgs.
PreviewText Gets 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.

Preview - GetPreviewText

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