Back to Devexpress

TreeList.GetPrintPreviewText Event

windowsforms-devexpress-dot-xtratreelist-dot-treelist-b31eec3b.md

latest4.4 KB
Original Source

TreeList.GetPrintPreviewText Event

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

Declaration

csharp
[DXCategory("Printing")]
public event GetPreviewTextEventHandler GetPrintPreviewText
vb
<DXCategory("Printing")>
Public Event GetPrintPreviewText As GetPreviewTextEventHandler

Event Data

The GetPrintPreviewText 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

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).

csharp
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();
}
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") + _
      "; 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

PreviewFieldName

GetPreviewText

PrintPreview

AutoCalcPreviewLineCount

TreeList Class

TreeList Members

DevExpress.XtraTreeList Namespace