New to Telerik UI for WinForms? Download free 30-day trial

Printing Hierarchical Grid

When bound to hierarchical data RadGridView can print its contents preserving the original hierarchical structure. This article will explain in details what settings need to be configured and how they should be applied. For the purpose of this example we will generate our hierarchy binding to the Northwind sample database. Here is how the resulting grid, looks when printed.

Figure 1: Printing Hierarchical Grid

WinForms RadGridView Printing Hierarchical Grid

Printing Settings

GridPrintStyle style = new GridPrintStyle();
style.PrintHierarchy = true;
style.HierarchyIndent = 20;
style.ChildViewPrintMode = ChildViewPrintMode.SelectViewToPrint;
this.radGridView1.PrintStyle = style;

Dim style As New GridPrintStyle()
style.PrintHierarchy = True
style.HierarchyIndent = 20
style.ChildViewPrintMode = ChildViewPrintMode.SelectViewToPrint
Me.RadGridView1.PrintStyle = style

GridPrintSyle Properties

The following properties of the GridPrintSyle class are responsible for defining the settings of a hierarchical RadGridView while it is being printed.

  • PrintHierarchy: Indicates whether the hierarchy will be printed or not.

  • HierarchyIndent: Defines indent in pixels for the different levels of the hierarchy.

ChildViewPrintMode Enumeration

Determines how child views are being printed when the grid is in hierarchy.

  • PrintFirstView: Always prints the first view.

  • PrintCurrentlyActiveView: Prints the view that is active in the grid.

  • ChildViewPrintMode: This mode raises the ChildViewPrinting event.


ChildViewPrinting: The event allows to choose the view to print on a row by row basis. It is raised for hierarchy rows with more than one child view. The event arguments provide:

  • ActiveViewIndex: Returns the index of the view to be printed.

  • Row: Gives access to the current GridViewHierarchyRowInfo.

See Also

In this article