WinControlContainer Class
A container that is used to embed a Control class instance or descendants into a report.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v19.2.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
Remarks
Use this class to add a Windows Forms control to a report. Use the PrintableComponentContainer class to add DevExpress controls, IPrintable controls, or printing links.
Create a WinControlContainer class instance to add a control to a report. Assign the control instance to the WinControl property. Add the WinControlContainer instance to a report band.
You can specify how to render a control inside the WinControlContainer:
- The PrintMode property specifies whether to render a control as a Printing System brick or as an image.
- The ImageType property specifies if the image is a bitmap or a metafile. This property is in effect when a control is rendered as an image. See the PrintMode property description for more information.
- The SyncBounds property specifies if a control should synchronize its bounds with the container’s bounds.
- The WinControlChanged event occurs when a new control is assigned to the container.
See the Use Third-Party Controls topic for information.
Example
The code sample below creates a DataGridView control instance and adds this instance to a report. The sample specifies that the DataGridView control is printed as a bitmap image.
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
// ...
// Create an XtraReport instance.
XtraReport report = new XtraReport() {
Bands = {
new DetailBand()
}
};
// Create a DataGridView control instance.
DataGridView dataGridView = new DataGridView();
// Create a WinControlContainer instance for the data grid.
WinControlContainer winControlContainer = new WinControlContainer();
// Place the data grid inside the WinControlContainer.
winControlContainer.WinControl = dataGridView;
// Specify that the WM_PAINT message is used to print the control inside the WinControlContainer.
winControlContainer.DrawMethod = WinControlDrawMethod.UseWMPaint;
// Specify that the control inside the WinControlContainer is always printed as an image.
winControlContainer.PrintMode = WinControlPrintMode.AsImage;
// Specify that the printed image is a bitmap, not a metafile.
winControlContainer.ImageType = WinControlImageType.Bitmap;
// Specify that the control should synchronize its bounds with the WinControlContainer's bounds.
winControlContainer.SyncBounds = true;
// Add the printable component container to the report.
report.Bands[BandKind.Detail].Controls.Add(winControlContainer);