加载图像动态ReportView [英] Load image to ReportView dynamically

查看:151
本文介绍了加载图像动态ReportView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的名字是我和埃德需要从ReportView负荷的形象dinamic.How我能做到这一点?
我的工作Windows窗体,C#3.0和LINQ to SQL的,我需要负荷的形象,我的报告DINAMIC。

My name is Ed and i need load image from ReportView dinamic.How i can do this? I work windows forms,c# 3.0 and linq to sql, i need load image to my reports dinamic.

感谢。

推荐答案

我假设你是从C#中使用的Microsoft报表查看器组件,并且希望将图像添加动态报告。

I'm assuming that you are using the Microsoft Report Viewer Component from C# and you want to add an image to the report dynamically.

这当然是可能的,你需要创建一个byte []表示序列化的Bitmap属性的类。

This is certainly possible, you need to create a class with a byte[] property that represents the serialized bitmap.

class ReportImage {
    public byte[] Image {get;set;}

    // Other stuff here if you want...
}

设置此对象的属性的位图的每像素24位的序列化版本(即你的位图保存到一个MemoryStream,然后调用MemoryStream.ToArray())。您的必须的使用每像素24位,格式保存到的必须的是BMP,这似乎在报表查看器是必需的。

Set the property of this object the a 24 bit per pixel serialized version of your Bitmap (i.e. save your bitmap to a MemoryStream, then call MemoryStream.ToArray()). You must use 24 bits per pixel, and the format you save to must be BMP, this seems to be required in the Report Viewer.

您就可以绑定到目标数据源,(见的有关详细信息,MSDN文档绑定到对象,还看到了例如 )。使用图像项目在报表中显示图像。

You can then bind to the Object Data Source, (see the MSDN documentation for details on binding to Objects, also see the example here). Use the Image item to display your image in the report.

的限制是,在报告中的图片必须是固定的大小。你必须事先重采样图像到适合他们,或者像乔恩暗示,动态创建报表的RDLC文件。

The limitation is that the images in your report must be fixed size. You'll have to resample the images beforehand to fit them in, or, as Jon suggests, dynamically create the RDLC file for the report.

这篇关于加载图像动态ReportView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆