Printing in Windows Forms TreeView

29 Apr 20211 minute to read

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

TreeViewPrintDocument printDocument = new TreeViewPrintDocument(this.treeViewAdv1);
printDocument.Print();
'Convert the Treeview as printing document
Dim printDocument As New TreeViewPrintDocument(Me.treeViewAdv1)
'Print the contents of the Grid
printDocument.Print()

Printing_img1

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

Printing_img2