Printing in Windows Forms TreeView

3 Feb 20222 minutes to read

WinForms TreeView Control has in-built support for printing. To print the content of treeview, convert the treeview into the printable document using TreeViewPrintDocument.

using Syncfusion.Windows.Forms.Tools;

namespace WindowsFormsApp20

    public partial class Form1 : Form
        public Form1()
            //Convert the Treeview as printing document
            TreeViewPrintDocument printDocument = new TreeViewPrintDocument(this.treeViewAdv1);
            //Print the contents of the Grid
Imports Syncfusion.Windows.Forms.Tools

Namespace WindowsFormsApp20
    Public Partial Class Form1
        Inherits Form

        Public Sub New()
            'Convert the Treeview as printing document
            Dim printDocument As TreeViewPrintDocument = New TreeViewPrintDocument(Me.treeViewAdv1)
            'Print the contents of the Grid
        End Sub
    End Class
End Namespace


PrepareTreeImage is used to gets an image that shows the entire tree, not just what is visible on the form.