简体   繁体   English

在运行时将图像添加到Crystal报表

[英]Add Image To Crystal Report At Runtime

I would like to add an image to a crystal report at runtime. 我想在运行时将图像添加到水晶报告中。

I am currently doing this using a second data table containing only a byte field and then a blob field on the report. 我目前正在使用第二个数据表执行此操作,该数据表仅包含字节字段,然后在报表上包含blob字段。 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? 是否可以使用代码或其他方法添加图像?

I'm using crystal reports for visual studio 2010. Winforms project. 我正在为visual studio 2010使用水晶报告.Winforms项目。 Either C# or VB. 无论是C#还是VB。

If you want to store the logo on disk instead of in the database: 如果要将徽标存储在磁盘上而不是存储在数据库中:

  1. In Designer, insert a placeholder image. 在Designer中,插入占位符图像。
  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. 在那里输入路径,或提供提供它的公式。

At runtime, Crystal will substitute the image from the file. 在运行时,Crystal将替换文件中的图像。

If you want, you can use a parameter field in your formula. 如果需要,可以在公式中使用参数字段。 That way you can provide the path programmatically at runtime. 这样,您就可以在运行时以编程方式提供路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM