1283585 - How to modify a Crystal Report section using .NET inproc RAS SDK

SAP Knowledge Base Articles - public

1283585 - How to modify a Crystal Report section using .NET inproc RAS SDK


How to modify a Crystal Report section using .NET inproc RAS SDK


As the Section Controller has no "Modify" method, use a temporary section as shown below:

        ReportDocument m_boReportDocument;
        ISCDReportClientDocument m_boReportClientDocument;

        CrystalDecisions.ReportAppServer.ReportDefModel.Section m_boSection;
        CrystalDecisions.ReportAppServer.ReportDefModel.Section m_boSectionModified;

        // you need to use a temp object here
        CrystalDecisions.ReportAppServer.ReportDefModel.Section m_boSectiontemp;
        CrystalDecisions.ReportAppServer.ReportDefModel.ISCRArea m_boDArea;

         //Create a new ReportDocument
         m_boReportDocument = new ReportDocument();

          //Access the ReportClientDocument in the ReportDocument (EROM bridge)
          m_boReportClientDocument = m_boReportDocument.ReportClientDocument;

           //First determine which section should be modified
           m_boSection = m_boReportClientDocument.ReportDefController.ReportDefinition.DetailArea.Sections[0];

            //Area is necessary for temp adding of section
            //as you cannot leave a report with no sections
            m_boDArea = m_boReportClientDocument.ReportDefController.ReportDefinition.DetailArea;

            m_boSectionModified = m_boSection.Clone(true);
           //Create the new section object
            m_boSectiontemp = new CrystalDecisions.ReportAppServer.ReportDefModel.Section();

            //Set the properties for the temp section
            m_boSectiontemp.Kind = CrystalDecisions.ReportAppServer.ReportDefModel.CrAreaSectionKindEnum.crAreaSectionKindDetail;
            m_boSectiontemp.Name = "Detail2";
            m_boSectiontemp.Height = 100;
            m_boSectiontemp.Width = 11520;
            //Now add the temp section
            m_boReportClientDocument.ReportDefController.ReportSectionController.Add(m_boSectiontemp, m_boDArea, -1);
            //Remove the main section
            //modify the cloned main section with a new property value
            m_boSectionModified.Height = 1000;

            //Now add the modified section
            m_boReportClientDocument.ReportDefController.ReportSectionController.Add(m_boSectionModified, m_boDArea, -1);

            //Remove the temp section
            //as the order of sections has changed, we need to redeclare the section index
            m_boSectiontemp = m_boReportClientDocument.ReportDefController.ReportDefinition.DetailArea.Sections[0];

            // show in reportviewer
            crystalReportViewer1.ReportSource = m_boReportDocument;


modify section crystal reports .NET inproc RAS , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To


Crystal Reports 2008 V1 ; SAP Crystal Reports XI R2 ; SAP Crystal Reports, developer version for Microsoft Visual Studio