Share via


Adding Images to a Report (Visual Studio Report Designer)

An image is a report item that contains a reference to an image that is stored on the report server, embedded within the report, or stored in a database. An image can be a logo or picture that appears once on the report or it can be a picture that is repeated with rows of data. You can also use an image as a background for certain report items. You can get images from the following sources:

  • Database

  • External file share or Web site

  • Embedded locally within the report

You cannot use image files that have been added to a project.

Data-bound images can be displayed from binary data stored in a database. For example, the pictures that appear alongside product names in a product list are database images.

External images are specified as a URL that points to an image file. External images work well for logos and static pictures that are shared among several reports or Web pages.

Local report images are embedded in the report and then referenced. The image data is stored within the report definition and does not exist as a separate file. Embedded images ensure that the images are always available to the report, but they cannot be shared. Embedding an image increases the size of the report definition file. When you embed an image, Report Designer MIME-encodes the image and then stores it as text in the report definition.

How to add an Embedded Image to a Report

  1. Open the client report definition (.rdlc) file in graphical design mode.

  2. From the Report menu, select Embedded Images and add all of the images that you want to use in the report. If the Report menu is not available, click within the report design area.

  3. Drag the image control from the toolbox to the report layout. You must use the image control that is used for ReportViewer reports.

  4. Select the image and then open the Properties window in Visual Studio.

  5. Set Source to Embedded.

  6. Set Value to an image that is embedded in the report definition. You can choose which image to use from a drop-down list.

Using an External or Database Image to a Report

To use a database image, you can specify the database field that contains the image as long as the MIME type is JPG, PNG, or BMP. If the image is stored as a binary object, you must write an expression that converts the image to a supported type.

Using external images in a ReportViewer report is not enabled by default. To use an external image, you must set the EnableExternalImages property in your code. Depending on your network configuration, you might also need to bypass proxy settings to allow the external image to appear. You can add the following settings to the Web.config file to bypass the local proxy. When modifying your Web.config file, be sure to specify the name of the proxy server that is used in your network:

<system.net>

<defaultProxy>

<proxy usesystemdefault = "false"

bypassonlocal = "true"

proxyaddress = "https://< proxyservername >:80/" />

<defaultProxy>

</system.net>

Background Images

You can use an image as a background image in the body of the report or in a rectangle, text box, list, matrix, or table. A background image has the same properties as an image. You can also specify how the image is repeated to fill the background of the item.

Note

If you define a background image for the report body, but not the page header or footer, HTML reports will automatically use the same background image in all three regions of the report. If you do not want to use the background image in the header or footer, you must explicitly define a different image for those regions. If you do not want any image to appear in those regions, you can create and assign a small transparent image to the header or footer to create the effect of having no image at all.

To add a background image, do the following:

  1. Open the client report definition (.rdlc) file in graphical design mode.

  2. Select the report item to which you want to add a background image.

    Note

    Background images apply only to rectangle, text box, table, matrix, list, or report body items.

  3. In the Properties window, expand BackgroundImage, and then do the following:

    • For Source, select External, Embedded, or Database.

      Note

      To use an image from the project, select External.

    • For Value, type or select an expression that evaluates to the source of the image.

      If the Source property is set to External, the expression must evaluate to a valid path to an image. This can be a static path to an image hosted on a report server, or it can be a path based on a field. If the image is stored in the project, type the name of the image as it appears in the project.

      If the Source property is set to Embedded, the expression must evaluate to the name of an image that is embedded in the report. If the Source property is set to Database, the expression must evaluate to a field that contains binary image data.

    • For MIMEType, select the appropriate MIME type for the image.

      Note

      MIMEType applies only if the Source property is set to Database. If the Source property is set to External or Embedded, the value of MIMEType is ignored.

For BackgroundRepeat, select Repeat, NoRepeat, RepeatX, or RepeatY.

See Also

Concepts

Adding Rectangles, Lines, and Borders to a Report (Visual Studio Report Designer)
Creating Data Sources for a Report
Adding Data Regions to a Report (Visual Studio Report Designer)
Adding Interactivity, Visibility, and Navigation to a Report (Visual Studio Report Designer)
Defining a Report Layout (Visual Studio Report Designer)