XRPictureBox.ImageUrl Property
Bindable. Specifies a path to the image that the XRPictureBox control displays.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v20.1.dll
NuGet Packages: DevExpress.Reporting.Core, DevExpress.WindowsDesktop.Reporting.Core
Declaration
[DefaultValue("")]
[SRCategory(ReportStringId.CatData)]
public string ImageUrl { get; set; }
Property Value
Type | Default | Description |
---|---|---|
String | String.Empty | A path to the image displayed in the picture box. |
Remarks
You can set this property in the PictureBox’s smart tag.
Supported image formats: BMP, JPG, JPEG, GIF, TIF, TIFF, PNG, ICO, DIB, RLE, JPE, JFIF, EMF, WMF, SVG.
Specify an Image Path
You can assign both absolute and relative paths to the ImageUrl property.
An absolute path specifies a complete path to the image. If you move your application to another directory, you have to update the specified path.
A relative path refers to a location that is relative to the base directory. The following table details what folder you should take as the base directory.
Application in Visual Studio (Design Time or Runtime) | Deployed Application |
---|---|
The application project’s directory | The application’s directory |
Perform the following steps before you deploy your application to provide relative path resolution.
Desktop
- Set the images’ Copy to Output Directory property to Copy Always.
- Set the images’ Build Action property to Content.
To specify image paths relative to another directory (not the application’s BaseDirectory), set the global DXResourceDirectory variable.
ASP.NET Web Forms & MVC
- Set the images’ Copy to Output Directory property to Copy Always.
- Set the images’ Build Action property to Content.
-
An application with Web Reporting controls
Implement the following code in your application to allow access to the directory that contains images, since the Reporting controls provide access to URLs only.using System; using DevExpress.Security.Resources; // ... public class Global_asax : System.Web.HttpApplication { protected void Application_Start(object sender, EventArgs e) { // Set access rules to data string dataPath = Server.MapPath("Image Resources"); AccessSettings.StaticResources.TrySetRules(DirectoryAccessRule.Allow(dataPath)); } // ... }
An application prints or exports reports from code (does not include Web Reporting controls)
You do not have to set directory access rules.
Set the global DXResourceDirectory variable.
- An application with Web Reporting controls
You do not have to set this variable. The reporting controls resolve relative paths relatively to the application’s directory. An application prints or exports reports from code (does not include Web Reporting controls)
- An application with Web Reporting controls
ASP.NET Core
- Set the images’ Copy to Output Directory property to Copy Always.
- Set the images’ Build Action property to Content.
-
An application with Web Reporting controls
Implement the following code in your application to allow access to the directory that contains images, since the Reporting controls provide access to URLs only.using DevExpress.Security.Resources; // ... public class Startup { //... public void Configure(IApplicationBuilder app, IHostingEnvironment env) { // Set access rules to data string dataPath = System.IO.Path.Combine(contentPath, "Data"); string dataPath2 = System.IO.Path.Combine(contentPath, "wwwroot\\Resources"); AccessSettings.StaticResources.TrySetRules(DirectoryAccessRule.Allow(contentPath)); AccessSettings.StaticResources.TrySetRules(DirectoryAccessRule.Allow(dataPath, dataPath2)); //... } }
An application prints or exports reports from code (does not include Web Reporting controls)
You do not have to set directory access rules.
Set the global DXResourceDirectory variable.
- An application with Web Reporting controls
You do not have to set this variable. The reporting controls resolve relative paths relatively to the application’s directory. An application prints or exports reports from code (does not include Web Reporting controls)
public class Startup { //... public void Configure(IApplicationBuilder app, IHostingEnvironment env) { // Set the resource directory string contentPath = env.ContentRootPath; AppDomain.CurrentDomain.SetData("DXResourceDirectory", contentPath); //... } }
- An application with Web Reporting controls
Bind to the Report Data Source’s Field
Invoke the control’s smart tag. Expand the Expression drop-down list and select a data field. In this instance, the URL that specifies the image location is obtained from the data source.
Click the Expression option’s ellipsis button to invoke the Expression Editor. Use this editor to construct a binding expression that can include two or more data fields.
Refer to the PictureBox class description for more information on how to bind this control to the report data source’s field.
Assign an Image
If you want to save an image to the report definition, and not the image’s path, use the XRPictureBox.ImageSource property instead.
Note
After you set the ImageUrl property’s value, the XRPictureBox.ImageSource property is set to null (Nothing in Visual Basic).
After you set the XRPictureBox.ImageSource property’s value, the ImageUrl property is set to Empty.