A Microsoft Visual Studio .NET application uses the Crystal Reports XI for Visual Studio .NET SDK as the reporting development tool. The application previews a report that is grouped on a database field.
How can you programmatically change the field that is being used to group the data in the report?
To programmatically change the field that is being used to group the data in the report, use the 'ConditionField' property of the group.
The following sample code demonstrates how to change the group condition field for the first group in a report. The group condition field will be changed to a database field called 'Region'.
' Start of VB.NET sample code
Dim newGroupField As FieldDefinition
newGroupField = crReportDocument.Database.Tables(0).Fields("Region")
crReportDocument.DataDefinition.Groups(0).ConditionField = newGroupField
' End of VB.NET sample code
// Start of C# .NET sample code
newGroupField = crReportDocument.Database.Tables.Fields["Region"];
crReportDocument.DataDefinition.Groups.ConditionField = newGroupField;
// End of C# .NET sample code
The 'ConditionField' property is read-only in Crystal Reports 10. For information on how to change the group condition field in Crystal Reports 10 for Visual Studio .NET, refer to Note 1217328.
11 DOTNET DOT NET ORDER SORT SORTFIELD GROUPING ORDERING SORTING SORTED c2015310 Crystal Reports for Visual Studio Grouping GroupCondition property , c2016969 , KBA , BI-RA-CR , Crystal Reports designer or BusinessViews Manager , How To