XRPictureBox.Sizing Property
Specifies the image displaying mode in the Picture Box control.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.2.dll
NuGet Package: DevExpress.Reporting.Core
#Declaration
[DefaultValue(ImageSizeMode.Normal)]
[SRCategory(ReportStringId.CatBehavior)]
public ImageSizeMode Sizing { get; set; }
#Property Value
Type | Default | Description |
---|---|---|
Image |
Normal | One of the Image |
Available values:
Name | Description |
---|---|
Normal | The image is placed in the upper-left corner of the Picture Box. The image is clipped if it does not fit into the control’s bounds. |
Stretch |
The image is stretched or shrunk to fit into the current Picture Box dimensions. |
Auto |
The Picture Box size is adjusted to that of the image it contains. |
Center |
This option is obsolete. To achieve the same result, set the |
Zoom |
The image is sized proportionally (without clipping), so that it fits best within the Picture Box dimensions. If the height-to-width ratio of the control and the image are equal, the image will be resized to exactly fit into the control’s dimensions. Otherwise, the closest matching image side (height or width) will be sized to the control, and the other side will be sized proportionally (possibly leaving empty space within the control). |
Squeeze | If the Picture Box dimensions exceed that of the image it contains, the image is centered and shown full-size. Otherwise, the image is resized to fit into the control’s dimensions. |
Tile | The image is replicated within the Picture Box starting from the upper-left corner. The image is clipped if it does not fit into the control’s dimensions. |
Cover | The image is sized proportionally, so that it fits the Picture Box control’s entire area. If the height-to-width ratio of the control and the image are equal, the image is resized to exactly fit into the control’s dimensions. Otherwise, the least matching image side (height or width) is sized to the control, the other side is sized proportionally. The resulting image is centered as the control’s Image |
#Remarks
Use this property to specify how the image should be displayed within the XRPictureBox control.
Illustration | Description |
---|---|
The image is displayed with its original dimensions. | |
The image is stretched to fill both the control’s width and height. | |
The control’s dimensions are auto-adjusted to the image size. | |
The image is proportionally resized, so that it fits the control. | |
If the control’s dimensions exceed the image size, the image is centered and shown full-size. Otherwise, the image is resized to fit into the control’s dimensions. | |
The original image is replicated within the picture control starting from the upper-left corner. The replicated image is clipped if it does not fit in the picture control which contains it. |
To display the image in the middle of the control, set the XRPictureBox.Sizing
property to ImageSizeMode.Normal and the XRPictureBox.ImageAlignment property to ImageAlignment.MiddleCenter.
#Example
This example demonstrates how to create an XRPictureBox object and specify its properties.
using DevExpress.XtraPrinting;
using DevExpress.XtraPrinting.Drawing;
using DevExpress.XtraReports.UI;
using System.Drawing;
// ...
public XRPictureBox CreateXRPictureBox()
{
// Create an XRPictureBox instance.
XRPictureBox xrPictureBox = new XRPictureBox();
// Specify an image for the created XRPictureBox instance.
xrPictureBox.ImageSource = ImageSource.FromFile("Images\\Flags\\United_States_of_America.png");
// Uncomment these lines to get images from a data source.
// ExpressionBinding expressionBinding = new ExpressionBinding("BeforePrint", "ImageSource", "[Picture]");
// xrPictureBox.ExpressionBindings.Add(expressionBinding);
// Position the picture box within a document.
xrPictureBox.LocationF = new PointF(150F, 25F);
// Set the picture box size.
xrPictureBox.SizeF = new SizeF(160F, 120F);
// Set the picture box size mode.
xrPictureBox.Sizing = ImageSizeMode.AutoSize;
// Specify that the image in the picture box should use the default DPI value.
xrPictureBox.UseImageResolution = false;
return xrPictureBox;
}