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

get sub-reports from DLL and combo in a Mast report.

1 Answer 36 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
huiluo wang
Top achievements
Rank 1
huiluo wang asked on 29 Jun 2010, 06:05 AM
Hi, Telerik
     I like telerik first, I meet some problems, please help me.
     I have a project, it have about 80 simple reports(some simple table or Chart, all are limited in one page), in another master report, they want to select some of these reports and show them as a whole report and export to PDF. 
     I create them and save in a class library, names reprot_class, it have 80 simple reports, a master report, and a ReportBook , I put all 80 simple reports in ReportBook.  master report  report_all contains 80 subreports, without setting report source. Simple reports are names like r_01, r_02, r_03,.......each report have a datasource. Subreport in report_all names like s_01, s_02, s_03, s_04
    Then I create a new WinForm application,reference the dll(report_class.dll),  and a ReportVIewer, I define a varible of report_all from report_class, my questions are:
1. how can I get the 80 simple report from the report_class.dll dynamicly? I don't want to use their name to define many many varible for maybe they will add new reports, I want only update the report_class.dll when I add new reports.
2. how can I set the dataSource/ a textbox value  for each simple report in WinForm application, of course, not define many reports varible either.
3. in report_all, how to set the report_source for each subreport dynamicly , e.g,  user select r_01, r_02, r_03, r_04, r_05 for a report, then I need set s_01's reportSource as r_01,  s_02's reportSource as r_02, s_03's reportSource as r_03,.....    if user select  r_05, r_08, r_01, r_04, r_07 then I need set  s_01's reportSource as r_05, s_02's reportSource as r_08, s_03's reportSource as r_01, s_04's reportSource as r_04, s_05's reportSource as r_07,
4. last question, for some simple reprots, I need change their title or change the value for some textBox, how can I do it.

I have change the modifier of datasource, textboxes in simple report  to to public, otherwise they can not access from other program.

I hope you can understand my poor English.
Thank you and BR

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 30 Jun 2010, 03:57 PM
Hello huiluo wang,

You can use similar approach as the one we have implemented in the Telerik Reporting demos that came with your installation of Telerik Reporting. Check out the ReportLibrary ReportExplorer.cs and the WinDemo's ReportSelector.

Once the needed reports are instantiated you can set the Report's DataSource property, TextBox value and SubReport's Report as shown in the following code snippet:
Report report= Activator.CreateInstance(t) as Report;
//set a datasource to a report
report.DataSource = new System.Data.DataTable();
//set a value to a TextBox
Telerik.Reporting.TextBox textBox = (Telerik.Reporting.TextBox)report.Items.Find("textBox22", true)[0];
textBox.Value = "Test Value";
//set a DataSource to a SubReport's report
((Telerik.Reporting.SubReport)reportDocument.Items.Find("subReport1", true)[0]).ReportSource.DataSource = sqlDataSource2;
 //set a report to the SubReport
((Telerik.Reporting.SubReport)reportDocument.Items.Find("subReport1", true)[0]).ReportSource = new MyReport();
MainForm frm = new MainForm(report);

Sincerely yours,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
General Discussions
Asked by
huiluo wang
Top achievements
Rank 1
Answers by
Telerik team
Share this question