Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Print a TreeView Control

This example illustrates the usage of printing links to print standard Windows Forms controls. The XtraPrinting library contains printing links specifically designed for several common controls. The following code links a Microsoft TreeView control to a printing system and generates a report which lists the TreeView nodes.

using DevExpress.XtraPrintingLinks;
using DevExpress.XtraPrinting;
// ...

    // Create a new link.
    TreeViewLink treeViewLink1 = new TreeViewLink(printingSystem1);

    // Assign the TreeView control to be printed.
    treeViewLink1.TreeView = tvwSource;

    // Add the link to the collection.
    printingSystem1.Links.Add(treeViewLink1);
    printingSystem1.Links[0] = treeViewLink1;

    // Generate a report.
    printingSystem1.Links[0].CreateDocument();

    // Show the report to the user.
    printingSystem1.PreviewFormEx.Owner = this;
    printingSystem1.PreviewFormEx.Show();
See Also