在运行时基于报表中提供的文件路径加载图像. [英] load an image based on a provided filepath in the report at runtime.

查看:59
本文介绍了在运行时基于报表中提供的文件路径加载图像.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用C#进行编程,以便必须从xml模式文件中获取源代码
,从而向表单添加按钮,并创建水晶报表. (.xsd文件)具有两个字段,即名称,图像.....名称是字符串数据类型,图像是
数据类型base64Binary.现在,我必须在表单中添加一个Crystal Report Viewer,并且在运行该程序时,我们应该能够加载任何图像,即,通过单击按钮从磁盘添加任何图像,然后应显示该图像
在报告中图片列...

I have to program in C# such that I have to add a button to the form , and create a crystal report, by getting source
from the xml schema file(.xsd file) with two fields namely name,image..... name is string datatype and image is of
datatype base64Binary. Now i have to add a crystal report viewer to the form and whenthe program is run, we
should be able to load any image ,ie, by clicking the button add any image from the disk and that image should be displayed
in the report in  image column......


所以我要做的是
-创建支持图像的数据集
-创建支持该数据集的报告
-将数据加载到数据集中
-将数据集用作报表的数据源并在查看器中显示报表


so wht i have to do is
-create a dataset that supports images
-create a report that support this dataset
-load data in the dataset
-use the dataset as datasource for the report and show the report in the viewer

然后我在Vb中找到了一个代码...
请在c#中为我更改并说明如何做...

Then i found a code in Vb...
please change for me in c# and explain how to do...

我将粘贴编码部分
代码:
   私人Sub btnLoadImage_Click(ByVal发件人为System.Object,_
                ByVal e As System.EventArgs)         处理btnLoadImage.单击

       昏暗的dImage作为新的OpenFileDialog

如果ofdImage.ShowDialog = DialogResult.OK,则

;尝试

; '创建数据集的新实例
将dsImgRpt变暗为新的dsImageReport

          ;   '创建报告的新实例
将m_imagereport设为新rptImage

           ;   '在数据集中创建新行
Dim dr As dsImageReport.ImageRow = _
dsImgRpt.Image.NewImageRow

           ;   '设置行的各种元素
博士名称= ofdImage.FileName
'用字节数组填充此字段
            dr.Photo = GetImageData(ofdImage.FileName)

               '将新行添加到数据集
dsImgRpt.Image.Rows.Add(dr)

     将数据集用作报表的数据源
m_imagereport.SetDataSource(dsImgRpt)

    在报表查看器中显示报表
Me.crystalReportViewer1.ReportSource = m_imagereport

例外捕获

             MessageBox.Show(发生了错误:"& ex.Message)

           结束尝试

      如果

   结束Sub

   私有函数GetImageData(ByVal文件名作为字符串)作为Byte()

从磁盘加载映像并将其作为字节流返回的方法
Dim fs As System.IO.FileStream = _
新的System.IO.FileStream(文件名,_
打开,System.IO.FileAccess.Read)
Dim br As System.IO.BinaryReader =新System.IO.BinaryReader(fs)
返回(br.ReadBytes(Convert.ToInt32(br.BaseStream.Length)))

结束功能


,请帮助我..


please help me to do this..

B atista

推荐答案

标记为已死


这篇关于在运行时基于报表中提供的文件路径加载图像.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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