Insert Dynamic Images in Infragistics Reporting

Tom Puglisi / Wednesday, February 1, 2012

Infragistics Reporting is an awesome product that you can use to add reports to your applications. I know many of you have Windows Forms applications and are thinking of using the IG Reporting to quickly add a rich set of reports. I ALSO know that there are customers that have custom controls that they have invested TONS of time in creating, for example, custom scientific charts (wink!) and would LOVE to see them in the Infragistics Reports. Well, with the technique used in this article, you can do this, provided you can convert your custom control into an image. This technique takes advantage of the Infragistics Reporting product’s Image control’s ability to dynamically pick up images on the file system each time the report is generated. In this topic, I will use the Infragistics Windows Forms UltraWinChart as my “custom control that I want to add to the report”.

Download the sample here.

 

Logic

The execution logic is simple:

  • Convert your control into an image and save it to disk. The Infragistics UltraWinChart has a method for that, so it is easy.
  • Refresh your report
  • THAT’S IT!
        private void LoadData()
        {
            //Add dummy data to the chart control:
            this.ultraChart1.Data.DataSource = 
                Infragistics.UltraChart.Data.DemoTable.AllPositive();
            this.ultraChart1.Data.DataBind();

            //Dump an image of the chart control:
            this.ultraChart1.SaveTo(
                Application.StartupPath + @"\Images\A.jpg", 
                System.Drawing.Imaging.ImageFormat.Jpeg);

            //Render the report:
            this.ultraReportViewer1.RefreshReport();
        }

Project and Report Setup

That’s easy too. Add an Infragistics Reporting Image control to your report and set its ImageURL Property to a valid path and filename for your image. Remember, you will be generating that actual image and naming it as you have specified in the ImageURL Property, so keep that in mind.

That’s it! You can use this technique to dump ANY of your controls or anything else into an Image that will get picked up by the Infragistics Report at runtime!