A RDLC subreport without subreport processing event

795 Views Asked by At

I want to use subreport in my main report but without working or dealing with subreport processing event.

As I am making a generic form which will have the report viewer control, I just have to send a report to this control. the containing report may or may not have sub report.

Kindly suggest me any possible scenario or other reporting control which may fit in the above stated case.

View Model Code

Microsoft.Reporting.WinForms.LocalReport report = new Microsoft.Reporting.WinForms.LocalReport();
            var reportDataSource = new Microsoft.Reporting.WinForms.ReportDataSource { Name = "AllEmployeeData", Value = EmployeeList };
            report = new Microsoft.Reporting.WinForms.LocalReport();
            report.ReportEmbeddedResource = "RDLCReport.Reports.RptEmployee.rdlc";
            report.DataSources.Add(reportDataSource);
            //This is the event which publish and subscribed in view to display report
            EventAggregator.GetEvent<ShowReport>().Publish(new Dictionary<string, object>() { { "Rpt", report } });

View Code

 private void ShowReport(Dictionary<string, object> obj)
        {
            this.ReportViewer.Report = new RDLCPrinter((Microsoft.Reporting.WinForms.LocalReport)obj["Rpt"]);
            this.ReportViewer.SetFitToWindowMode();
        }
1

There are 1 best solutions below

1
On

The subreport processing event exists because the subreport would contain data, which is relative to the data showed in the main report.

For example:

You have Ivoices report. For each invoice, there is a list of products in this invoice. You get the products for the specific invoice in the Subreport processing event.

If you don't need to use the Subreport processing event, this means that you probably don't need to use subreports.