ソートは、データを昇順または降順に整理する方法です。FlexReport でソートを実行するには、DataSource.SortDefinitions を使用します。
たとえば、従業員の名前のリストを昇順に表示することにします。この場合は、リストを「名(First Name)」でソートする必要があります。以下の手順は、従業員リストの名前をアルファベット順にソートする方法を示します。この例では、「FlexReport クイックスタート」で作成したサンプルを使用します。
- FlexReport クイックスタートプロジェクトのフォームに、C1Button を追加します。
- C1Button の Name を「sortC1Button」に設定し、Text を「Sort Report by Employee First Name」に設定します。
- Click イベントを sortC1Button_Click という名前で作成します。
- 次のコードを追加します。
- レポートをプレビュー表示します。[Employees]ボタンをクリックして、レポートをレンダリングします。
- [Sort Report by Employee First Name]ボタンをクリックして、レポートのソート結果を表示します。

Sorting Data using FlexReportDesigner
The data in a report can be easily sorted using FlexReportDesigner. The steps to sort data in a report are as follows:
- Create a new report - Products Report - bound to Main data source through C1NWind.mdb. Select Product Name, Quantity Per Unit, and Stock as the text and calculated fields, so that the report appears as shown:

- To view the report where data is sorted by Product Name, go to Design mode.
- Click Data tab.
- Expand Data Sources node.
- Expand the Main data source to which the report is bound.
- Right-click Sort Definitions.

-
Select Add Sort Definition. Sort Definition dialog box appears.

-
Select ProductName, check the Ascending checkbox, and click OK.
-
Preview the report.
