Skip to main content

BestSizeEstimator.GetBoundsToFitContainer(XRControl) Method

Gets boundaries for the specified control to fit its parent container.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v23.2.dll

NuGet Package: DevExpress.Reporting.Core


public static RectangleF GetBoundsToFitContainer(
    XRControl control


Name Type Description
control XRControl

A control that should be fit to its parent container.


Type Description

A RectangleF structure specifying the resulting boundaries.


You can place specific report controls on a container, such as panel or table cell. In this case, a control’s Parent property provides access to this parent container.

When a container includes only one control, you can correctly position it using the GetBoundsToFitContainer method. This method returns optimal boundaries for the specified control to occupy the entire container space excluding borders. You can then apply the resulting rectangle to this control.

The code snippet below demonstrates how to create a new table and fit the XRPictureBox control to the first table cell using the GetBoundsToFitContainer method.

using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting; 

XRTable table = new XRTable() { Borders = BorderSide.All };
XRPictureBox pictureBox = new XRPictureBox() {
    ImageUrl = "C:\\MyImage.png",
    Sizing = ImageSizeMode.Squeeze
table.HeightF = 200f;
XRTableCell cell1 = new XRTableCell() {
    WidthF = 300f,
    Controls = { pictureBox }
XRTableRow row = new XRTableRow() {
    HeightF = 200f,
    Cells = {cell1 , new XRTableCell() {
        Text = "Cell", WidthF = 300f }
pictureBox.BoundsF = BestSizeEstimator.GetBoundsToFitContainer(pictureBox);
// ...


The GetBoundsToFitContainer method returns boundaries of the specified control itself if the control’s Parent property is set to null:

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetBoundsToFitContainer(XRControl) method.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also