Skip to main content

Use Third-Party Controls

  • 3 minutes to read

This document describes how to add third-party visual elements to a report. Apart from standard controls, a report can contain controls from the System.Windows.Forms namespace, printing links or custom user-defined objects.

Embed Third-Party WinForms Controls

You can add a Windows Forms control to a report at Visual Studio design time by copying and pasting this control from its Form designer. A WinControlContainer hosts this control after adding it to the report.

Controls - UsingWindowsForms1

A report can contain any Windows Forms visual control that supports the .NET drawing engine (based on the Graphics class that provides support for GDI+). XtraReports cannot host Win32 or ActiveX components for this reason.

Use the WinControlContainer.DrawMethod property to specify the rendering mode of a Windows Forms control.

Handle the XRControl.Draw event of a corresponding WinControlContainer to provide a custom logic during the rendering of a control.

You can print standard Windows Forms controls using the following appropriate printing links:

Embed DevExpress WinForms Controls

You can add a DevExpress WinForms control to a report using a PrintableComponentContainer. It enables printing documents created using printing links as well as objects that implement the IPrintable interface. The following DevExpress controls implement this interface.

Do the following to embed such a control to a report:

  1. Prepare a WinForms application containing the controls you want to print (for instance, the GridControl in this example).


  2. Add a new empty report to your WinForms application.
  3. Open the Visual Studio Toolbox (by pressing CTRL+ALT+X) and expand its DX.23.1: Report Controls tab. Drag the PrintableComponentContainer control from this tab and drop it onto the report’s detail band.


  4. Change the added container’s modifier to public to be able to assign the required properties outside of the XtraReport class descendant scope.
  5. Specify the PrintableComponentContainer.PrintableComponent property to associate the Windows Forms controls with the corresponding report containers. Use the methods of the ReportPrintTool class to invoke the default Print Preview form and show a report document in it.

    using System.Windows.Forms;
    // Create a new report instance.
    XtraReport1 report = new XtraReport1();
    // Link the required control with the PrintableComponentContainers of a report.
    report.printableComponentContainer1.PrintableComponent = gridControl;
    // Invoke a Print Preview for the created report document. 
    ReportPrintTool preview = new ReportPrintTool(report);

The following image illustrates the resulting report document containing a WinForms control.


Embed DevExpress ASP.NET Controls

You can embed the following DevExpress web controls into a report using the corresponding exporter objects:

ASP.NET Web Forms Control Exporter
ASPxGridView ASPxGridViewExporter
ASPxCardView ASPxCardViewExporter
ASPxVerticalGrid ASPxVerticalGridExporter
ASPxPivotGrid ASPxPivotGridExporter
ASPxTreeList ASPxTreeListExporter
ASP.NET MVC Control Exporter
MVCxGridView MVCxGridViewExporter
MVCxPivotGrid MVCxPivotGridExporter
MVCxTreeList MVCxTreeListExporter
MVCxCardView MVCxCardViewExporter
MVCxVerticalGrid MVCxVerticalGridExporter

Assign an exporter object to the PrintableComponentContainer.PrintableComponent property in code to embed the corresponding control into a report.

An online example is available at How to print DevExpress ASP.NET controls via XtraReports.

See Also