1913575 - How to delete a group field from a Crystal report at runtime?

SAP Knowledge Base Article - Public

1913575 - How to delete a group field from a Crystal report at runtime?

Symptom

How to delete a group field from a Crystal report at runtime?

Environment

  • Crystal Reports 2008 / SAP Crystal Reports, Developer version for Microsoft Visual Studio.
  • Visual Studio 2008 / Visual Studio 2010

Resolution

Here is C# sample code developed using Crystal Reports InProc RAS .NET SDK to delete a group from a report.

CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

rd.Load(Server.MapPath("CrystalReport1.rpt"));

ISCDReportClientDocument boReportClientDocument;

boReportClientDocument = rd.ReportClientDocument;
int groupCount = boReportClientDocument.DataDefinition.Groups.Count;

if (groupCount > 0)

{

for (int i = 0; i < groupCount; i++)

{

CrystalDecisions.ReportAppServer.DataDefModel.Group group = boReportClientDocument.DataDefinition.Groups[i];
// Remove the group

boReportClientDocument.DataDefController.GroupController.Remove(group);

CrystalReportViewer1.ReportSource = rd;

}

}

Keywords

bi, sap, beginner, business_intelligence_(businessobjects), sap_crystal_reports, visual, for, .net, crforvs, crvs2010, studio, sdk, crystal_reports, cr.net, cr, formula, crystal_reports_for_visual_studio_2010, _version_for_visual_studio_.net, business_intelligence_(business, crystal_reports_2008, groupfield, group expert, crystal_report, code_resuability, crvs, cr2008, ras.net, cr4vs2010, vs2012, Visual studio 2012, .net 4, crfor .net , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To

Product

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