SAP Knowledge Base Article - Public

2055165 - How to suppress multiple report sections using the Crystal Reports SDK for Visual Studio .NET

Symptom

  • A report has a number (n) of sections.
  • Depending on user requirement, the report needs to suppress n-x sections.
  • What code will accomplish this requirement?

Environment

  • SAP Crystal Reports, Developer Version for Visual Studio .NET.
  • Microsoft Visual Studio .NET (2010 / 2012 / 2013).

Resolution

  • Use the InProcRAS SDK that is part of SAP Crystal Reports, Developer Version for Visual Studio .NET.
  • The following code uses a For loop to iterate through the report sections:

 

ReportDocument rd = new ReportDocument();
                ISCDReportClientDocument crReportClientDocument = rd.ReportClientDocument;
                CrystalDecisions.ReportAppServer.ReportDefModel.SectionFormat crSectionFormat;
                CrystalDecisions.ReportAppServer.ReportDefModel.Section crSection;
                rd.Load("E:\\SouthGis\\CASS\\Code\\trunk\\Code\\ShowReport\\ShowReport\\CRReport\\CrystalReport_ALLCR.rpt");
               for (int i = 0; i < crReportClientDocument.ReportDefController.ReportDefinition.ReportFooterArea.Sections.Count; i++)
               {
                    if (<whatever criteria determines whether to suppress this section....>
                    {
                          crSection = crReportClientDocument.ReportDefController.ReportDefinition.ReportFooterArea.Sections[i];
                          crSectionFormat = crSection.Format;
                          crSectionFormat.EnableSuppress = true;
                         crReportClientDocument.ReportDefController.ReportSectionController.SetProperty
                         (crSection, CrystalDecisions.ReportAppServer.Controllers.CrReportSectionPropertyEnum.crReportSectionPropertyFormat,
                         crSectionFormat);
                    }
               }

Keywords

crvs code sample example vr4vs solution developer kit cr , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio