Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何添加报告rdlc图像参数以从应用程序设置获取图像?_C#_Winforms - Fatal编程技术网

C# 如何添加报告rdlc图像参数以从应用程序设置获取图像?

C# 如何添加报告rdlc图像参数以从应用程序设置获取图像?,c#,winforms,C#,Winforms,在我的WinForms应用程序中,不同的用户在应用程序上工作。每个用户都使用自己的徽标和名称,我将其存储在应用程序设置中。现在,我想在报告上显示应用程序设置图像。我已经在谷歌上搜索过了,根据我的搜索,没有人会这样说。以下是我发现并尝试的内容: this.reportViewer1.LocalReport.EnableExternalImages = true; string imgFrom = new Uri(Properties.Settings.Default.system_img).A

在我的WinForms应用程序中,不同的用户在应用程序上工作。每个用户都使用自己的徽标和名称,我将其存储在应用程序设置中。现在,我想在报告上显示应用程序设置图像。我已经在谷歌上搜索过了,根据我的搜索,没有人会这样说。以下是我发现并尝试的内容:

 this.reportViewer1.LocalReport.EnableExternalImages = true;
 string imgFrom = new Uri(Properties.Settings.Default.system_img).AbsolutePath;
 ReportParameter parameter = new ReportParameter("img", imgFrom);
 this.reportViewer1.LocalReport.SetParameters(parameter);
在此之前,我在报告中添加了一个参数。但这对我来说不起作用。
有人能告诉我怎么做吗?

在编辑代码并对上面的代码做了两次更改后,它工作得很好。以下是变化:

this.reportViewer1.LocalReport.EnableExternalImages = true;
string imgFrom = new Uri(Properties.Settings.Default.system_img).AbsoluteUri; // changed from AbsolutePath to AbsoluteUri
                        ReportParameter rpImg = new ReportParameter("img", imgFrom);
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp1, rp2, rpImg }); // add the parameter to another set of parameters that I had before.

服务器无权访问用户本地文件夹。您必须将图像作为参数发送,或者必须将图像放在SQL server可以访问文件的文件夹(如网络文件夹)中。