windowsforms-devexpress-dot-xtratreelist-dot-treelist-b31eec3b.md
Enables you to display custom text in preview sections when the control is printed.
Namespace : DevExpress.XtraTreeList
Assembly : DevExpress.XtraTreeList.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList
[DXCategory("Printing")]
public event GetPreviewTextEventHandler GetPrintPreviewText
<DXCategory("Printing")>
Public Event GetPrintPreviewText As GetPreviewTextEventHandler
The GetPrintPreviewText 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. |
The Tree List control’s printed version contains preview sections if the TreeListOptionsPrint.PrintPreview option is enabled. The TreeList.PreviewFieldName property and TreeList.GetPreviewText event specify the default contents of preview sections.
To provide custom text for preview sections when the control is printed, handle the GetPrintPreviewText event.
See the Print TreeList topic for details on printing the control.
The code below handles the TreeList.GetPreviewText and TreeList.GetPrintPreviewText events to specify different preview section content for the control when it is displayed on-screen and when it is printed (text is displayed on two lines).
using DevExpress.XtraTreeList;
treeList1.OptionsView.ShowPreview = true;
private void treeList1_GetPreviewText(object sender, GetPreviewTextEventArgs e) {
e.PreviewText = "Office location: " + e.Node["Location"].ToString() +
"; Contact phone: " + e.Node["Phone"].ToString();
}
private void treeList1_GetPrintPreviewText(object sender, GetPreviewTextEventArgs e) {
e.PreviewText = "Office location: " + e.Node["Location"].ToString() +
"\nContact phone: " + e.Node["Phone"].ToString();
}
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") + _
"; Contact phone: " + e.Node("Phone")
End Sub
Private Sub TreeList1_GetPrintPreviewText(ByVal sender As Object, _
ByVal e As GetPreviewTextEventArgs) Handles TreeList1.GetPrintPreviewText
e.PreviewText = "Office location: " + e.Node("Location") + _
vbCrLf + "Contact phone: " + e.Node("Phone")
End Sub
See Also