BestSizeEstimator.GetBoundsToFitContainer(XRControl) Method
Gets boundaries for the specified control to fit its parent container.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.2.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
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:
- for XRPivotGrid, XRSubreport, XRPageBreak, XRTableOfContents, XRCrossBandLine and XRCrossBandBox controls since they cannot be added to containers;
- for other controls if they are not placed in a container.
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetBoundsToFitContainer(XRControl) method.
Note
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.