SAP Knowledge Base Article - Public

1671624 - How to find the ReportObjects on sub report in Crystal Report using Crystal Reports .NET SDK?

Symptom

How to find the ReportObjects on sub report in Crystal Report using Crystal Reports .NET SDK?

Environment

  • Crystal Reports for Visual Studio 2010
  • Crystal Reports 2008 V1

 

Resolution

Following is the code that can be used to find the ReportObjects on the sub report:

private void FindSubReportsinMainReport(ReportDocument reportDocument)
 {
  if (reportDocument.Subreports.Count > 0)
   {
    foreach (ReportDocument rdoc in reportDocument.Subreports)
     {
      if (rdoc.ReportDefinition.ReportObjects.Count > 0)
       {
         Response.Write("</br>");
         Response.Write("<table border=1 cellspacing=2>");
         Response.Write("<tr>");
         Response.Write("<td><b>Report Object Name</b></td>");
         Response.Write("<td><b>Report Kind</b></td>");
         Response.Write("<td><b>Report Object Format</b></td>");
         Response.Write("</tr>");
         foreach (ReportObject reportObject in rdoc.ReportDefinition.ReportObjects)
          {
            Response.Write("<tr>");
            Response.Write("<td>" + reportObject.Name + " </td>");
            Response.Write("<td>" + reportObject.Kind.ToString() + " </td>");
            Response.Write("<td>" + reportObject.ObjectFormat.ToString() + " </td>");
            Response.Write("</tr>");
          }
        Response.Write("</table>");
       }
     }
   } 
 }

Most of the objects inherit the properties of ReportObject, some of them inherit all and some few. Here's list for all of them:

BlobFieldObject 
ChartObject Properties  
CrossTabObject 
FlashObject Properties  
GraphicObject 
MapObject
OlapGridObject 
PictureObject 
BoxObject
DrawingObject 
FieldHeadingObject 
FieldObject
LineObject  
SubReportObject 
TextObject

Keywords

object report text formula blobfield , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To

Product

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