Reputation: 627
How do i get subreport name in C# ?
i have one main report and one subreport.In my C# code i need to get the subreportName.
rptDynamicReport rpt = new rptDynamicReport(); // CrystalReport
//i need somethig like this
string reportName = "Multiple";// Where multiple is the sub report name
Upvotes: 2
Views: 5639
Reputation: 25197
using CrystalDecisions.CrystalReports.Engine;
//snip
//Where report is the parent rpt of type ReportDocument (or a subclass of ReportDocument)
foreach(ReportDocument subreport in rpt.Subreports)
{
if(subreport.Name = "Multiple")
{
//Not the most elegant solution, but should work
SubreportObject subrpt = (SubreportObject)subreport;
subrpt.Height = 0;
}
}
Per your request I have added the hiding functionality, I haven't tested this out and haven't done any hiding of subreports personally. I think that this should work. I couldn't find any "Visible" property or anything like that.
Upvotes: 3