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

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

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);
//Note: when removing group by index you lessen the group count by 1 each time a group is removed
// recommended to remove group by name not index
// or remove groups in reverse order.
groupCount--;


}
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