Dynamically change an image in a Crystal Report at runtime

后端 未结 8 1246
天命终不由人
天命终不由人 2021-02-04 08:08

I\'m using the Crystal Reports included with VisualStudio 2005. I would like to change the image that is displayed on the report at runtime ideally by building a path to the ima

8条回答
  •  醉梦人生
    2021-02-04 09:03

    I also had this question (and voted yours up)!

    [I have since found a solution using a byte array via a C# Object property - see separate Answer. Leaving this answer here for reference...]

    Here's what I have seen suggested (but I tried and failed in both C#-2005 and C#-2008).

    1. Choose a directory and place a BMP there (e.g., "C:\Temp\image.bmp").
    2. From the CR-Designer a) Right-click->Insert->OLE Object... b) Select "Create from File" c) Check the "Link" checkbox d) Browse and pick the bmp defined in step 1 e) Click OK f) Place the image on the form.
    3. Overwrite/update the image at runtime in your C# code. In theory, since you inserted a Link to an image file, it will be updated when the form is refreshed.

    I had no luck with this approach. The image appears when I first design the form (step 2). But at runtime, the image does not update for me. From this point forward, things get really odd. It seems that CR caches some sort of image that just won't go away. I can delete the OLE object link in CR-Designer, but if I recreate it, I always get a black box the same size as the original image (even if I change the size of image.bmp).

提交回复
热议问题