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.
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.
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.
You can print standard Windows Forms controls using the following appropriate printing links:
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:
Prepare a WinForms application containing the controls you want to print (for instance, the GridControl in this example).
Open the Visual Studio Toolbox (by pressing CTRL+ALT+X) and expand its DX.19.1: Report Controls tab. Drag the PrintableComponentContainer control from this tab and drop it onto the report's detail band.
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); preview.ShowRibbonPreview();
The following image illustrates the resulting report document containing a WinForms control.
You can embed the following DevExpress web controls into a report using the corresponding exporter objects:
|ASP.NET WebForms Control||Exporter|
|ASP.NET MVC Control||Exporter|
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.