xtrareports-devexpress-dot-xtrareports-dot-ui-dot-bestsizeestimator-dot-getboundstofitcontainer-x28-devexpress-dot-xtrareports-dot-ui-dot-xrcontrol-x29.md
Gets boundaries for the specified control to fit its parent container.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
public static RectangleF GetBoundsToFitContainer(
XRControl control
)
Public Shared Function GetBoundsToFitContainer(
control As XRControl
) As RectangleF
| Name | Type | Description |
|---|---|---|
| control | XRControl |
A control that should be fit to its parent container.
|
| Type | Description |
|---|---|
| RectangleF |
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.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);
// ...
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraPrinting
'...
Dim table As New XRTable() With {.Borders = BorderSide.All}
Dim pictureBox As New XRPictureBox() With {
.ImageUrl = "C:\MyImage.png",
.Sizing = ImageSizeMode.Squeeze}
table.BeginInit()
table.HeightF = 200F
Dim cell1 As New XRTableCell() With {
.WidthF = 300F,
.Controls = { pictureBox }
}
Dim row As New XRTableRow() With {
.HeightF = 200F,
.Cells = {cell1, New XRTableCell() With {
.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