Programatically Accessing Subreports

Stimulsoft Reports.NET discussion
Post Reply
raja
Posts: 12
Joined: Wed Aug 08, 2007 6:32 am

Programatically Accessing Subreports

Post by raja »

Hi,
I am tryign to access all subreports that are part of the main report. But it is always giving me there are no subreports. I tried to test this with the sample subreport that is part of the demo (SideBySideListWithSubReports.mrt)..

Here is the code

Code: Select all


StiReport stiReport1 = new StiReport();
stiReport1.Load("SideBySideListWithSubReports.mrt");

foreach (StiReport report in stiReport1.SubReports) {
    //do something for each report..
}

It loads the report properly but it never gets to for loop. Am i missing something here..

Thanks in advance
-Raja
Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Programatically Accessing Subreports

Post by Guest »

For work with subreports of the report you must have access to subreports by using components of the report:

Code: Select all

foreach (StiComponent component in stiReport1.Pages[0].GetComponents())
 {
      if (component is StiSubReport)
      {
          StiSubReport subreport = (component as StiSubReport);
           //do something for subreport...
      }    
}
Thank you.
raja
Posts: 12
Joined: Wed Aug 08, 2007 6:32 am

Programatically Accessing Subreports

Post by raja »

Pavel wrote:For work with subreports of the report you must have access to subreports by using components of the report:

Code: Select all

foreach (StiComponent component in stiReport1.Pages[0].GetComponents())
 {
      if (component is StiSubReport)
      {
          StiSubReport subreport = (component as StiSubReport);
           //do something for subreport...
      }    
}
Thank you.
Thank you.. I will try using GetComponents.
Post Reply