1910091 - How to swap group condition fields of groups in Crystal report using Crystal Reports VS .NET SDK?

SAP Knowledge Base Article - Public

1910091 - How to swap group condition fields of groups in Crystal report using Crystal Reports VS .NET SDK?

Symptom

How to swap group condition fields of groups in Crystal report using Crystal Reports.NET SDK?

Environment

  • SAP Crystal Reports, developer version for Microsoft Visual Studio.
  • Visual Studio 2012.

Resolution

C# code to swap group condition fields of 2 groups:

ReportDocument report = new ReportDocument();
report.Load("CrystalReport1.rpt");
MessageBox.Show(
String.Format("Before: Condition fields are {0} and {1}",
report.DataDefinition.Groups[0].ConditionField.FormulaName,
report.DataDefinition.Groups[1].ConditionField.FormulaName));
FieldDefinition group0Field = report.DataDefinition.Groups[0].ConditionField;
FieldDefinition group1Field = report.DataDefinition.Groups[1].ConditionField;
report.DataDefinition.Groups[1].ConditionField = group0Field;

report.DataDefinition.Groups[0].ConditionField = group1Field;
MessageBox.Show(
String.Format("After: Condition fields are {0} and {1}",
report.DataDefinition.Groups[0].ConditionField.FormulaName,
report.DataDefinition.Groups[1].ConditionField.FormulaName));

Keywords

Swapping groups; Swap group condition fields , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio