This is a migrated thread and some comments may be shown as answers.

Assigning Report programmatically

2 Answers 191 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Pete
Top achievements
Rank 1
Pete asked on 02 Jun 2009, 12:36 PM
Hi, I have an empty winform that I add the controls dynamically at runtime, depending on the value in a dropdown.

If one of the options in the combobox is a telerik report I've already set up called Report1 how can I programmatically assign this to a new ReportViewer and add the ReportViewer control at runtime, is this possible ? Thanks

2 Answers, 1 is accepted

Sort by
0
Gary
Top achievements
Rank 1
answered on 04 Jun 2009, 10:07 AM
Pete

To assign the report to the view just do somthing similar to this

                Report1 report = new Report1();  
                reportViewer.Report = report;  
                reportViewer.RefreshReport();  
 

I have a reportviewer on a panel that I make visible/invisible if the user has selected a certain report and load the report as per the previous code.

There maybe a better way of doing this but it works for me. I then just change the report each time the user selects the relevant report.
0
Pete
Top achievements
Rank 1
answered on 05 Jun 2009, 07:33 AM
Hi Gary, thanks for this. Thats exactly what I did, I was trying to set the report equal to a string name but when I referenced the report it worked fine. Thanks again.

Pete.
Tags
General Discussions
Asked by
Pete
Top achievements
Rank 1
Answers by
Gary
Top achievements
Rank 1
Pete
Top achievements
Rank 1
Share this question
or