The requested page is not available for the requested platform. You are viewing the content for Default platform.

BestSizeEstimator.GetBoundsToFitContainer(XRControl) Method

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

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll

Declaration

public static RectangleF GetBoundsToFitContainer(
    XRControl control
)
Public Shared Function GetBoundsToFitContainer(
    control As XRControl
) As RectangleF

Parameters

Name Type Description
control XRControl

A control that should be fit to its parent container.

Returns

Type Description
RectangleF

A RectangleF structure specifying the resulting boundaries.

Remarks

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.BeginInit();
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 }
    }
};
table.Rows.Add(row);
table.EndInit();
pictureBox.BoundsF = BestSizeEstimator.GetBoundsToFitContainer(pictureBox);
// ...
Note

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

See Also