Tall Boy

Tall Boy

  • NA
  • 7
  • 975

Writing a multi report reportviewer in win forms

Apr 16 2017 6:38 AM
Hi,
 
I am trying to write a win forms app in c# using a reportviewer such that the users chooses  a report from a list of reports and depending on the report the reportviewer shows the chosen report at run time. I was able to do it using vb.net previously but finding followinfgthe same pattern in c# is not working. I've searched the web but nof found anything similar..
 
Here is my code any ideas? 
 
Here the load event code...
  1. var setup = this.reportViewer1.GetPageSettings();  
  2.                 setup.Landscape = false//Portrait  
  3.                 setup.Margins = new System.Drawing.Printing.Margins(1, 1, 1, 1);  
  4.                 this.reportViewer1.SetPageSettings(setup);  
  5.                 //Me.ReportViewer1.Reset()  
  6.                 //ReportViewer1.LocalReport.DataSources.Clear()  
  7.                 ReportDataSource CurrentReportDataSource = new ReportDataSource();  
  8.                 switch (ReportNo) {  
  9.                     case 1: {  
  10.                             //        'TODO: This line of code loads data into the 'CAMHSDataSet.ShowAllWaitingAtEndOfMonth' table. You can move, or remove it, as needed.  
  11.                             this.GetPatientDetailsTableAdapter.Fill(this.MediClinicDB1DataSet.GetPatientDetails, PatientID);  
  12.                             this.reportViewer1.LocalReport.ReportEmbeddedResource = "MediPraticeOne.RptPatientReferral.rdlc";  
  13.   
  14.                             CurrentReportDataSource.Name = "GetPatientDetails";  
  15.                             CurrentReportDataSource.Value = GetPatientDetailsBindingSource;  
  16.                             reportViewer1.LocalReport.DataSources.Add(CurrentReportDataSource);  
  17.                             //  Pass in 1 report parameters  
  18.                             ReportParameter[] parameters = new ReportParameter[1];  
  19.                             parameters[0] = new ReportParameter("PatientID"this.PatientID.ToString());  
  20.                             this.reportViewer1.LocalReport.SetParameters(parameters);  
  21.                             //  setup.Landscape = true;  
  22.                             break;  
  23.                         }  
  24.                     //    Case 2  
  25.                     //        '' Show All Patients at Month End  
  26.                     //        this.ShowCurrentPatientsAtEndOfMonthTableAdapter.Fill(Me.CAMHSDataSet1.ShowCurrentPatientsAtEndOfMonth, EndDate)  
  27.                     //        reportViewer1.LocalReport.ReportEmbeddedResource = "BusinessReports.RptAllPatientsMonthEnd.rdlc"  
  28.                     //         
  29.   
  30.   default: {  
  31.                             MessageBox.Show("No Report found");  
  32.                             break;  
  33.                         }  
  34.                 }  
  35.                 
  36.                 this.reportViewer1.RefreshReport();  
 any suggesstions appreicated!

Answers (2)