You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助:通过参数将PictureBox条码传递至report.rdlc时遇空值错误

解决RDLC报表传递非常规格式条码图片的"value should not be null"错误

RDLC报表的图片控件仅支持PNG、JPG这类标准图片格式,你直接用Image.RawFormat保存条码时,生成了报表无法解析的格式,导致参数传递后控件无法识别,抛出空值错误。只需把条码转成标准格式再处理即可,修改后的代码如下:

Dim ms As New MemoryStream
' 强制将条码图片保存为PNG格式(报表支持的标准格式)
Form1.PictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
Dim arrPic As Byte() = ms.ToArray
Dim images As String = Convert.ToBase64String(arrPic)

Dim param As IList(Of ReportParameter) = New List(Of ReportParameter)
param.Add(New ReportParameter("Address", Form1.TextBox4.Text))
' 第三个参数设为True,表示是嵌入的图片
param.Add(New ReportParameter("img", images, True))     
ReportViewer1.LocalReport.SetParameters(param)
Me.ReportViewer1.RefreshReport()

额外注意两个检查点:

  • 报表内的图片控件,右键属性→「来源」选择「外部」
  • 报表参数名称要和代码里的img完全一致,大小写、拼写都不能出错

内容的提问来源于stack exchange,提问作者Joel Leoj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 10:55:23