xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrpicturebox.md
Do not load files obtained from untrusted sources. Such files may pose a security risk. Please review the following article for additional information:
Suppress Control Requests to Download Data from External URLs
Bindable. Specifies a path to the image that the XRPictureBox control displays.
Namespace : DevExpress.XtraReports.UI
Assembly : DevExpress.XtraReports.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
[DefaultValue("")]
[SRCategory(ReportStringId.CatData)]
public string ImageUrl { get; set; }
<SRCategory(ReportStringId.CatData)>
<DefaultValue("")>
Public Property ImageUrl As String
| Type | Default | Description |
|---|---|---|
| String | String.Empty |
A path to the image displayed in the picture box.
|
You can set the ImageUrl property in the Picture Box control’s smart tag:
Supported image formats: BMP, JPG, JPEG, GIF, TIF, TIFF, PNG, ICO, DIB, RLE, JPE, JFIF, EMF, WMF, SVG.
You cannot load physical images from the web server’s file directory. This rule is due to security considerations. To allow the “file://“ protocol in image URLs, use the AccessSettings class to apply necessary access rules.
You can assign an absolute or relative path to the ImageUrl property.
An absolute path is the path to the local file or an image URL. To retrieve an image using a URL from a web server, anonymous access is used.
A relative path refers to the location relative to the base directory. The following table shows which folder is considered to be the base directory :
| Application in Visual Studio (Design Time or Runtime) | Deployed Application |
|---|---|
| The application project directory | The application directory |
Before deployment, you must configure the application to ensure that relative paths are resolved correctly. Follow the steps below that describe how to configure the application on different platforms.
For all resource files (image or document), do the following:
To specify paths relative to another directory (not the application BaseDirectory ), set the global DXResourceDirectory variable:
// Set the resource directory to the MyResources folder in the user profile.
string dataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "MyResources");
AppDomain.CurrentDomain.SetData("DXResourceDirectory", dataPath);
' Set the resource directory to the MyResources folder in the user profile.
Dim dataPath As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "MyResources")
AppDomain.CurrentDomain.SetData("DXResourceDirectory", dataPath)
You have two options – either use the DirectoryAccessRule class or set the DXResourceDirectory global variable.
An application includes Web Reporting controls.
Implement the following code snippet in your application to allow access to a directory that contains resources (images or documents), since Reporting controls only allow access to URLs.
An application prints or exports reports from code and does not include Web Reporting controls.
There is no need to set directory access rules.
You have two options – either use the DirectoryAccessRule class or set the DXResourceDirectory global variable.
An application includes Web Reporting controls.
Implement the following code snippet in your application to allow access to a directory that contains resources (images or documents), since Reporting controls only allow access to URLs.
An application prints or exports reports from code and does not include Web Reporting controls.
There is no need to set directory access rules.
When you edit a report in the Web Report Designer, the relative path to the image is calculated based on the domain used by your application. If you switch to preview mode, the image path is calculated as described earlier in this section.
The ImageUrl property is bindable. You can invoke the Expression Editor and specify an expression whose value is the path to the image:
Select the control in the Report Designer, click the smart tag, and expand the drop-down list in the Expression editor below the Image Source field. In the following image, the URL that specifies the image location is obtained from the PhotoPath data source field:
Click the ellipsis button to invoke the Expression Editor. Use this editor to construct an expression. For more information, review the following help topic: Bind Report Controls to Data Using Expression Bindings.
If you want to store an image in the report layout (REPX file), use the XRPictureBox.ImageSource property instead of the ImageUrl property.
ImageUrlproperty’s value, the XRPictureBox.ImageSource property is set to null (Nothing in Visual Basic).ImageUrl property is set to Empty.The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ImageUrl property.
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.
XRPictureBox icon = new XRPictureBox();
icon.ImageUrl = Server.MapPath(@"~/App_Data/Images/dxlogo.png");
icon.HeightF = 50;
Dim icon As New XRPictureBox()
icon.ImageUrl = Server.MapPath("~/App_Data/Images/dxlogo.png")
icon.HeightF = 50
See Also