The requested page is not available for the requested platform. You are viewing the content for Default platform.

XRPictureBox.ImageUrl Property

Bindable. Specifies a path to the image that the XRPictureBox control displays.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll

Declaration

[SRCategory(ReportStringId.CatData)]
[DefaultValue("")]
public string ImageUrl { get; set; }
<SRCategory(ReportStringId.CatData)>
<DefaultValue("")>
Public Property ImageUrl As String

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.

ImageUrl-SmartTag

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.

ASP.NET WebForms & MVC

  • Set the images' Copy to Output Directory property to Copy Always.
  • Set the images' Build Action property to Content.
  • Set directory access rules.

    • 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.

      public class Global : 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)

      public class Global : System.Web.HttpApplication {
      
        protected void Application_Start(object sender, EventArgs e) {
            // Set the resource directory
            string contentPath = Server.MapPath("");
            AppDomain.CurrentDomain.SetData("DXResourceDirectory", contentPath);
        }
        // ...
      }
      

ASP.NET Core

  • Set the images' Copy to Output Directory property to Copy Always.
  • Set the images' Build Action property to Content.
  • Set directory access rules.

    • 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.

      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(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);
              //...
          }
      }
      

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.

ImageUrl-BindToDataSourceField

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.

See Also