# TreeList.ShowPrintPreview() Method | WinForms Controls | DevExpress Documentation

# TreeList.ShowPrintPreview() Method

Opens the Print Preview window, which displays commands in bars.

**Namespace**: [DevExpress.XtraTreeList](/WindowsForms/DevExpress.XtraTreeList)

        **Assembly**:
        DevExpress.XtraTreeList.v26.1.dll

## Declaration

- C#
- VB.NET

                        <section id="tabpanel_syntax_tabid_DevExpress.XtraTreeList.TreeList.ShowPrintPreview-csharp" role="tabpanel" data-tab="tabid-csharp" class="tab-group__tab-content tab-group__tab-content--code" style="display: block">
                            <pre><code class="lang-csharp hljs">public void ShowPrintPreview()</code></pre>
                        </section>
                        <section id="tabpanel_syntax_tabid_DevExpress.XtraTreeList.TreeList.ShowPrintPreview-vb" role="tabpanel" data-tab="tabid-vb" class="tab-group__tab-content tab-group__tab-content--code" style="display: none">
                            <pre><code class="lang-vb hljs">Public Sub ShowPrintPreview</code></pre>
                        </section>

## Remarks

The [ShowRibbonPrintPreview()](/WindowsForms/DevExpress.XtraTreeList.TreeList.ShowRibbonPrintPreview) method invokes the **Preview** window that allows a user to do the following:

- select the control’s visual elements to be printed
- set the page size, orientation, and margins
- specify headers and footers
- navigate through the preview
- select a printer, set the number of copies, and print the control
- export the data to different formats (PDF, HTML, XLS, etc.)

![Tree List Ribbon Print Preview](/WindowsForms/images/tree-list-printing-ribbon-print-preview.png)

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.

### Print Preview Commands

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()](/WindowsForms/DevExpress.XtraTreeList.TreeList.PrintDialog) method to invoke this dialog.

      ![Tree List Print Dialog](/WindowsForms/images/tree-list-printing-print-dialog.png)
- **Print Quick** — prints the control without the print dialog. You can call the [Print()](/WindowsForms/DevExpress.XtraTreeList.TreeList.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](/WindowsForms/DevExpress.XtraTreeList.TreeList.OptionsPrint) property to specify these options in code.

      ![Tree List Print Options](/WindowsForms/images/tree-list-printing-print-options.png)

Note that you can only print controls if the project references the [XtraPrinting library](/WindowsForms/2079/controls-and-libraries/printing-exporting). To check if the control can be printed, use the [IsPrintingAvailable](/WindowsForms/DevExpress.XtraTreeList.TreeList.IsPrintingAvailable) property. To check if the control is currently being printed, use the [IsPrinting](/WindowsForms/DevExpress.XtraTreeList.TreeList.IsPrinting) property.

## Example

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](/WindowsForms/DevExpress.XtraTreeList.TreeList.IsPrintingAvailable) property. The example also uses the following methods:

- [TreeList.ShowRibbonPrintPreview](/WindowsForms/DevExpress.XtraTreeList.TreeList.ShowRibbonPrintPreview) — to show the print preview.
- [TreeList.Print](/WindowsForms/DevExpress.XtraTreeList.TreeList.Print) — to print the control.

![Tree List Print Preview](/WindowsForms/images/printing-the-xtratreelist_preview4297.png)

- C#
- VB.NET

<section id="tabpanel_gEpoo3At5e_tabid-csharp" role="tabpanel" data-tab="tabid-csharp">
<pre><code data-code-links="{&quot;/ (DevExpress.XtraTreeList)(?:;|$)/&quot;:&quot;/WindowsForms/DevExpress.XtraTreeList&quot;,&quot;/ (DevExpress.XtraEditors)(?:;|$)/&quot;:&quot;/WindowsForms/DevExpress.XtraEditors&quot;}" class="lang-csharp">using DevExpress.XtraTreeList;
using DevExpress.XtraEditors;

private void ShowTreeListPreview(TreeList treeList) {
    if (!treeList.IsPrintingAvailable) {
        XtraMessageBox.Show(&quot;Print library not found&quot;, &quot;Error&quot;);
        return;
    }
    treeList.ShowRibbonPrintPreview();
}

private void PrintTreeList(TreeList treeList) {
    if (!treeList.IsPrintingAvailable) {
        XtraMessageBox.Show(&quot;Print library not found&quot;, &quot;Error&quot;);
        return;
    }
    treeList.Print();
}
</code></pre></section>
<section id="tabpanel_gEpoo3At5e_tabid-vb" role="tabpanel" data-tab="tabid-vb" aria-hidden="true" hidden="hidden">
<pre><code data-code-links="{&quot;/ (DevExpress.XtraTreeList)(?:;|$)/&quot;:&quot;/WindowsForms/DevExpress.XtraTreeList&quot;,&quot;/ (DevExpress.XtraEditors)(?:;|$)/&quot;:&quot;/WindowsForms/DevExpress.XtraEditors&quot;}" class="lang-vb">Imports DevExpress.XtraTreeList
Imports DevExpress.XtraEditors

Sub ShowTreeListPreview(ByVal treeList As TreeList)
   If Not treeList.IsPrintingAvailable Then
      XtraMessageBox.Show(&quot;Print library not found&quot;, &quot;Error&quot;)
      Return
   End If
   treeList.ShowRibbonPrintPreview()
End Sub

Sub PrintTreeList(ByVal treeList As TreeList)
   If Not treeList.IsPrintingAvailable Then
      XtraMessageBox.Show(&quot;Print library not found&quot;, &quot;Error&quot;)
      Return
   End If
   treeList.Print()
End Sub
</code></pre></section>

See Also

[Print Tree List](/WindowsForms/311/controls-and-libraries/tree-list/feature-center/print-tree-list)

[IsPrintingAvailable](/WindowsForms/DevExpress.XtraTreeList.TreeList.IsPrintingAvailable)

[Print()](/WindowsForms/DevExpress.XtraTreeList.TreeList.Print)

[ShowRibbonPrintPreview()](/WindowsForms/DevExpress.XtraTreeList.TreeList.ShowRibbonPrintPreview)

[PrintDialog()](/WindowsForms/DevExpress.XtraTreeList.TreeList.PrintDialog)

[TreeList Class](/WindowsForms/DevExpress.XtraTreeList.TreeList)

[TreeList Members](/WindowsForms/DevExpress.XtraTreeList.TreeList._members)

[DevExpress.XtraTreeList Namespace](/WindowsForms/DevExpress.XtraTreeList)