Click here to Skip to main content
15,916,188 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am doing a project in c# using visual studio 2012. I want to prepare RDLC report form one form and the send it to report viewer control which is in another form. So that I use only one report viewer control for all reports. I did thousands of reports following this process in VB.net using RDLC and Crystal Report. But I can not do this in c# using RDLC. Following is what I did in VB.net.

Dim objreport As New frmReportViwer
Dim rds As ReportDataSource = New ReportDataSource("dsReportData", dt)
objreport.rvrReportViwer.LocalReport.DataSources.Clear()
objreport.rvrReportViwer.LocalReport.DataSources.Add(rds)
objreport.rvrReportViwer.RefreshReport()
objreport.Show()

I can not access report viewer control of other form in C#. Can any one help me?

What I have tried:

What I tried as follow-
public SaleSlipViwer objreportviwer = null; // SaleSlipViwer is the form in which I placed the report viewer

public PointOfSale()
{
InitializeComponent();
objreportviwer = new SaleSlipViwer();
}

And then try to access ReportViewer this way

objreportviwer.rvrReportViwer.LocalReport.DataSources.Clear();

But it does not work.
Posted
Updated 7-Mar-16 19:48pm
Comments
CHill60 4-Mar-16 8:32am    
Have a look at the series of articles by OriginalGriff - Transferring information between two forms, Part 1: Parent to Child[^]
The simplest (but probably not the best) solution would be to make the control public
Member 12360367 4-Mar-16 11:22am    
Tried your link but still no luck!@Chill60

use sub reports in main report.this is the way to show multiple report.
 
Share this answer
 
Comments
Member 12360367 5-Mar-16 1:56am    
I just looking for a way to do in C# as I did in VB.net as I described in my post. Is there any?
I have solved it. It was an issue of form modifier to set public.
Thank you very much.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900