在运行时将图像添加到Crystal Report

问题描述:

我想在运行时将图像添加到Crystal报表中.

I would like to add an image to a crystal report at runtime.

我目前正在使用第二个数据表来执行此操作,该数据表仅包含一个字节字段,然后在报表上包含一个blob字段.但是,这感觉像是黑客,如果第一个主表中没有数据,则由于某种原因,该图像将不会显示.

I am currently doing this using a second data table containing only a byte field and then a blob field on the report. However this feels like a hack and if there is no data in the first primary table then for some reason the image does not show.

是否可以使用代码或其他方法添加图像?

Is it possible to add an image with code or another method?

我正在为Visual Studio 2010使用Crystal报表.Winforms项目. C#或VB.

I'm using crystal reports for visual studio 2010. Winforms project. Either C# or VB.

如果要将徽标存储在磁盘上而不是数据库中:

If you want to store the logo on disk instead of in the database:

  1. 在Designer中,插入一个占位符图像.
  2. 右键单击占位符图像,然后单击设置图形格式.在图片标签上,点击图形位置旁边的公式按钮.在此处输入路径,或提供提供该路径的公式.
  1. In Designer, insert a placeholder image.
  2. Right-click the placeholder image, and click Format Graphic. On the Picture tab, next to Graphic Location, click the formula button. Enter the path there, or provide a formula which provides it.

在运行时,Crystal将替换文件中的图像.

At runtime, Crystal will substitute the image from the file.

如果需要,可以在公式中使用参数字段.这样,您可以在运行时以编程方式提供路径.

If you want, you can use a parameter field in your formula. That way you can provide the path programmatically at runtime.