Back to Devexpress

WinControlContainer Class

xtrareports-devexpress-dot-xtrareports-dot-ui-fd1ed2c5.md

latest6.0 KB
Original Source

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.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
public class WinControlContainer :
    XRControl
vb
Public Class WinControlContainer
    Inherits XRControl

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.

csharp
using DevExpress.XtraReports.UI;
using System.Windows.Forms;
// ...
// Create an XtraReport instance.
XtraReport report = new XtraReport()
{
    Bands = {
        new DetailBand()
    }
};
// Create a DataGrid control instance.
DataGridView dataGridView = new DataGridView();
// Create a PrintableComponentContainer instance for the data grid.
PrintableComponentContainer printableComponentContainer = new PrintableComponentContainer();
// Place the data grid inside the printable component container.
printableComponentContainer.WinControl = dataGridView;
// Specify that the control inside the printable component container is always printed as an image.
printableComponentContainer.PrintMode = WinControlPrintMode.AsImage;
// Specify that the control inside the printable component container is always printed as a bitmap.
printableComponentContainer.WindowControlOptions.ImageType = WinControlImageType.Bitmap;
// Add the printable component container to the report.
report.Bands[BandKind.Detail].Controls.Add(printableComponentContainer);
vb
Imports DevExpress.XtraReports.UI
' ...
' Create an XtraReport instance.
Dim report = New XtraReport()
Dim band = New DetailBand()
report.Bands.Add(band)
' Create a DataGrid control instance.
Dim dataGridView As New DataGridView()
' Create a PrintableComponentContainer instance for the data grid.
Dim printableComponentContainer As New PrintableComponentContainer()
' Place the data grid inside the printable component container.
printableComponentContainer.WinControl = dataGridView
' Specify that the control inside the printable component container is always printed as an image.
printableComponentContainer.PrintMode = WinControlPrintMode.AsImage
' Specify that the control inside the printable component container is always printed as a bitmap.
printableComponentContainer.WindowControlOptions.ImageType = WinControlImageType.Bitmap
' Add the printable component container to the report.
report.Bands(BandKind.Detail).Controls.Add(printableComponentContainer)

Implements

IScriptable

Inheritance

Object MarshalByRefObject Component XRControl WinControlContainer PrintableComponentContainer

See Also

WinControlContainer Members

Use Third-Party Controls

PrintableComponentContainer

DevExpress.XtraReports.UI Namespace