windowsforms-devexpress-dot-xtratreelist-dot-treelist-4daddc39.md
Opens the Print Preview window, which displays commands in bars.
Namespace : DevExpress.XtraTreeList
Assembly : DevExpress.XtraTreeList.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList
public void ShowPrintPreview()
Public Sub ShowPrintPreview
The ShowRibbonPrintPreview() method invokes the Preview window that allows a user to do the following:
Commands in the window are displayed in the ribbon. You can also call the ShowPrintPreview() method, which invokes the print preview window where commands are displayed in bars.
A user can call the following commands in the ribbon:
Print — invokes the print dialog, which allows a user to select a printer, specify the number of copies, define the page range, and print the control. You can call the PrintDialog() method to invoke this dialog.
Print Quick — prints the control without the print dialog. You can call the Print() method to print the control without the print dialog.
Options — invokes a window that allows a user to specify the visual elements that should be printed: vertical grid lines, headers, etc. You can use the OptionsPrint property to specify these options in code.
Note that you can only print controls if the project references the XtraPrinting library. To check if the control can be printed, use the IsPrintingAvailable property. To check if the control is currently being printed, use the IsPrinting property.
The code below displays a notification if the control cannot be printed. To check whether it is possible to print the control, the code uses the IsPrintingAvailable property. The example also uses the following methods:
using DevExpress.XtraTreeList;
using DevExpress.XtraEditors;
private void ShowTreeListPreview(TreeList treeList) {
if (!treeList.IsPrintingAvailable) {
XtraMessageBox.Show("Print library not found", "Error");
return;
}
treeList.ShowRibbonPrintPreview();
}
private void PrintTreeList(TreeList treeList) {
if (!treeList.IsPrintingAvailable) {
XtraMessageBox.Show("Print library not found", "Error");
return;
}
treeList.Print();
}
Imports DevExpress.XtraTreeList
Imports DevExpress.XtraEditors
Sub ShowTreeListPreview(ByVal treeList As TreeList)
If Not treeList.IsPrintingAvailable Then
XtraMessageBox.Show("Print library not found", "Error")
Return
End If
treeList.ShowRibbonPrintPreview()
End Sub
Sub PrintTreeList(ByVal treeList As TreeList)
If Not treeList.IsPrintingAvailable Then
XtraMessageBox.Show("Print library not found", "Error")
Return
End If
treeList.Print()
End Sub
See Also