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()
{
InitializeComponent();
//Convert the Treeview as printing document
TreeViewPrintDocument printDocument = new TreeViewPrintDocument(this.treeViewAdv1);
//Print the contents of the Grid
printDocument.Print();
}
}
}
Imports Syncfusion.Windows.Forms.Tools
Namespace WindowsFormsApp20
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
'Convert the Treeview as printing document
Dim printDocument As TreeViewPrintDocument = New TreeViewPrintDocument(Me.treeViewAdv1)
'Print the contents of the Grid
printDocument.Print()
End Sub
End Class
End Namespace
Print Preview
PrepareTreeImage is used to gets an image that shows the entire tree, not just what is visible on the form.