Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai all,

In C#, How can I Suppress Crystal Report's Subreport programmatically..?

Please help..
Posted
Updated 2-Aug-16 16:25pm

I know I'm way late to answer this question, but seeing as how I was searching long and hard for a more appropriate (in my opinion) solution to the same problem, I figured I'd go ahead and share it here. You can access the subreports directly and directly suppress them like this:

C#
// Here, subreportName is the name of the object, not the name of the file
var subrpt = (SubreportObject)report.ReportDefinition.ReportObjects["subreportName"];

subrpt.ObjectFormat.EnableSuppress = true;


I far prefer to directly manipulate the object model where possible... especially because it allows me to avoid messing with scripts in Crystal, which are not very intuitive to me
 
Share this answer
 
You want to set the Suppress flag to be conditional on a parameter value using a formula, then set the param from code.

You'll have to toggle that flag in the designer (to conditionally suppress the subreport). You can then do something like this to set the param:
report.SetParameterValue("suppressSubReport", 1, "NameOfSubreport");


Hope this helps.

Cheers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900