Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically Load Embedded Resource Report Using Microsoft.Reporting.WinForms

How does one dynamically load a new report from an embedded resource? I have created a reporting project that contains a report as an embedded resource. I added a second report file and use the following code to switch reports:

this.reportViewer1.LocalReport.ReportEmbeddedResource = "ReportsApplication2.Report2.rdlc";
this.reportViewer1.LocalReport.Refresh();
this.reportViewer1.RefreshReport();

When this code executes, the original report remains visible in the report viewer.

I have also tried using

LocalReport.LoadReportDefinition

but had the same result.

like image 988
Craig Eddy Avatar asked Oct 02 '08 15:10

Craig Eddy


1 Answers

The answer: you have to call

<ReportViewer>.Reset();

prior to changing the value of ReportEmbeddedResource or calling LoadReportDefinition.

After you do so, you'll also have to call

<ReportViewer>.LocalReport.DataSources.Add( ... );

to re-establish the data sources.

like image 147
Craig Eddy Avatar answered Sep 19 '22 01:09

Craig Eddy