Search code examples
crystal-reportssubreport

set subreport via code


I have three reports (main.rpt, sub1.rpt, sub2.rpt). In the main.rpt, in section 2, I have a empty subreport (without connection to the data).

I would decide, via code c#, whether to show sub1.rpt or sub2.rpt inside subreport in section 2 of the main.

I use this to show main report:

 r.Load("main.rpt");
 r.SetDataSource(dset);
 crystalReportViewer1.ReportSource = r;
 // HOW SHOW sub1.rpt or sub2.rpt in main's section2?

Suggestions? Thank you very much


Solution

  • Try:

     r.Subreports("Your Sub report").SetDataSource(dset)