David T. Macknet
David T. Macknet

Reputation: 3162

Dynamically load pictures from file system into Crystal Report (VS 2008 version)

I have a VB.NET application which needs to generate reports (invoices) which contains optional images. The images are going to be loaded into 1 of 6 places on the report, but will reside on the client PC (deployed with the application). I've been trying to access the ICROleObject object, which is what's placed onto the report, but I can't locate this interface in the object browser, even. As this is the object's interface, I figured that it would let me access it if only I could cast it:    

 CType(r.ReportDefinition.ReportObjects("picTL"), ICROleObject)
Any ideas where I would find this, or if I'm even approaching this correctly?
I've tried following the directions at http://www.idautomation.com/crystal/streaming_crystal.html, and that won't work with the version of Crystal which is embedded in .NET 2008. Neither will the solution found at http://www.a1vbcode.com/a1vbcode/vbforums/Topic25620-3-1.aspx#bm25974, although that one looks a bit more promising, and is the one I'm trying to model after.
If I have to use a dataset & a series of subreports, I suppose could ... but that method just doesn't seem as straightforward as this one.

Upvotes: 0

Views: 8477

Answers (2)

Alessandro Bernardi
Alessandro Bernardi

Reputation: 399

My approach has been setting a Crystal Reports Parameter to define which image should be visibile and then customize the Suppress formula using this parameter. I had a crystal reports exception in exporting report which was caused by manipulating report objects from outside the report, even if print preview was working fine.

Upvotes: 1

Karl
Karl

Reputation:

You should cast it as a PictureObject instead. The type "PictureObject" is found in the CrystalDecisions.CrystalReports.Engine namespace.

Ex:

Dim pic = CType(rapportCourant.ReportDefinition.ReportObjects("Picture1"), PictureObject) pic.ObjectFormat.EnableSuppress = True

You can then suppress ou enable the picture object as you need it.

Upvotes: 1

Related Questions