Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
Writing a multi report reportviewer in win forms
Tall Boy
Apr 16 2017 6:38 AM
248
Reply
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...
var setup =
this
.reportViewer1.GetPageSettings();
setup.Landscape =
false
;
//Portrait
setup.Margins =
new
System.Drawing.Printing.Margins(1, 1, 1, 1);
this
.reportViewer1.SetPageSettings(setup);
//Me.ReportViewer1.Reset()
//ReportViewer1.LocalReport.DataSources.Clear()
ReportDataSource CurrentReportDataSource =
new
ReportDataSource();
switch
(ReportNo) {
case
1: {
// 'TODO: This line of code loads data into the 'CAMHSDataSet.ShowAllWaitingAtEndOfMonth' table. You can move, or remove it, as needed.
this
.GetPatientDetailsTableAdapter.Fill(
this
.MediClinicDB1DataSet.GetPatientDetails, PatientID);
this
.reportViewer1.LocalReport.ReportEmbeddedResource =
"MediPraticeOne.RptPatientReferral.rdlc"
;
CurrentReportDataSource.Name =
"GetPatientDetails"
;
CurrentReportDataSource.Value = GetPatientDetailsBindingSource;
reportViewer1.LocalReport.DataSources.Add(CurrentReportDataSource);
// Pass in 1 report parameters
ReportParameter[] parameters =
new
ReportParameter[1];
parameters[0] =
new
ReportParameter(
"PatientID"
,
this
.PatientID.ToString());
this
.reportViewer1.LocalReport.SetParameters(parameters);
// setup.Landscape = true;
break
;
}
// Case 2
// '' Show All Patients at Month End
// this.ShowCurrentPatientsAtEndOfMonthTableAdapter.Fill(Me.CAMHSDataSet1.ShowCurrentPatientsAtEndOfMonth, EndDate)
// reportViewer1.LocalReport.ReportEmbeddedResource = "BusinessReports.RptAllPatientsMonthEnd.rdlc"
//
default
: {
MessageBox.Show(
"No Report found"
);
break
;
}
}
this
.reportViewer1.RefreshReport();
any suggesstions appreicated!
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Multi Columns filtered gridview
how to add 0 row in database Windows Application #