This tutorial illustrates how to group a report against a custom criteria at design time within Visual Studio. In the report created in this example, products are grouped by a calculated field that returns the first letter of the product name.
Do the following to group a report by a custom field:
To create a table report in this tutorial, start with a report that is bound to the "Products" table of the sample Northwind database (the nwind.mdb file included in the XtraReports installation). To learn more about binding a report to a data source, see Provide Data to Reports.
To create a calculated field, switch to the Field List, right-click any item inside the nwindDataSet1 and select Add Calculated Field in the menu that is invoked.
As a result, the CalculatedField.DataMember property is automatically set to the "Products" table of the project's data set, which means that the calculated field can access data fields from this table.
If the panel is not displayed, you can make it visible by checking the corresponding item in the XtraReports Menu.
To create a grouping criteria, click Add a Group and select the calculated field from the invoked drop-down menu.
You can also use this panel to specify whether or not the corresponding Group Footer band should be visible. The Sort Order drop-down list allows you to define the sort order within the group (ascending or descending) or disable sorting in grouped data.
Next, switch to the Field List and drop the required data fields onto the report's Detail band, and the Initial calculated field onto the Group Header area.