SAP Knowledge Base Article - Public

1306234 - How to add a box to a report using the Crystal Reports .NET inproc RAS SDK

Symptom

How to add a box to a report using the Crystal Reports .NET inproc RAS SDK ?

Reproducing the Issue

  • Crystal Reports XI Release 2 Service Pack 2 and later 
  • C#
  • Resolution

    sample code:


               using CrystalDecisions.CrystalReports.Engine;
               using CrystalDecisions.ReportAppServer.ClientDoc;


                //CR Declarations
                ReportDocument                                                                                      m_boReportDocument;
                ISCDReportClientDocument                                                                  m_boReportClientDocument;
            

                CrystalDecisions.ReportAppServer.ReportDefModel.Section          m_boSectionStart;
                CrystalDecisions.ReportAppServer.ReportDefModel.Section          m_boSectionEnd;
                CrystalDecisions.ReportAppServer.ReportDefModel.BoxObject      m_boBox;


               

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

                //load the RPT file
                m_boReportDocument.Load("..\\..\\DummyReport.rpt");

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


                //first determine the sections to start and end on - in this case the page header section
                m_boSectionStart = m_boReportClientDocument.ReportDefController.ReportDefinition.PageHeaderArea.Sections[0];
                m_boSectionEnd = m_boReportClientDocument.ReportDefController.ReportDefinition.PageHeaderArea.Sections[0];

                //create a new Box object
                m_boBox = new CrystalDecisions.ReportAppServer.ReportDefModel.BoxObject();

                //set its properties
                m_boBox.Right = 10000;
                m_boBox.Bottom = 1000;
                m_boBox.Left = 10;
                m_boBox.Top = 10;
                m_boBox.FillColor = 16;

                m_boBox.LineThickness = 15;
                m_boBox.LineStyle = CrystalDecisions.ReportAppServer.ReportDefModel.CrLineStyleEnum.crLineStyleSingle;
                m_boBox.SectionName = m_boSectionStart.Name;
                m_boBox.EndSectionName = m_boSectionEnd.Name;

                //does this go into other sections ?
                m_boBox.EnableExtendToBottomOfSection = false;

                //set the section code for the section it is being added to
                m_boBox.SectionCode = m_boSectionStart.SectionCode;

                //add to the report
                m_boReportClientDocument.ReportDefController.ReportObjectController.Add(m_boBox, m_boSectionStart, 0);

                //display in reportviewer
                crystalReportViewer1.ReportSource = m_boReportDocument;

    Keywords

    How add box report Crystal Reports .NET inproc RAS SDK , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To

    Product

    SAP Crystal Reports XI R2