Skip to main content

TreeList.GetPrintPreviewText Event

Enables you to display custom text in preview sections when the control is printed.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v23.2.dll

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

Declaration

[DXCategory("Printing")]
public event GetPreviewTextEventHandler GetPrintPreviewText

Event Data

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.

Remarks

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.

Example

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