The CategorySelection sample demonstrates passing a SQL string into a report at run time. It consists of a CategorySelectForm and CategoryProducts report.
<User Folder>\ComponentOne Samples\ActiveReports Developer 7\Section Reports\VB.NET\Layout\CategorySelection
<User Folder>\ComponentOne Samples\ActiveReports Developer 7\Section Reports\C#\Layout\CategorySelection
When you run this sample, a form containing a Viewer control and a ComboBox control within a panel is displayed. The Select a Product Category ComboBox at the top of the form allows the users to select the type of data they want to display in the Viewer control.
Note: To run this sample, you must have access to the Nwind.mdb. A copy is located at [User Documents folder]\ComponentOne Samples\ActiveReports Developer 7\Data\NWIND.mdb. If you are unable to access the data files in the sample, create the Data folder and place all the data files to this folder, or change the reference path to the data files within the folder according to your environment. |
The Viewer control fills most of the form, and a ComboBox at the top allows the user to select which data to send to the Viewer control.
To see how all of this works, right-click the form and select View Code.
- The getCategories code populates the ComboBox with the category names.
- The runCategoryReport code runs the report with a SQL string with the CategoryName passed in by the ComboBox selection.
- The SelectIndexChanged event calls runCategoryReport and passes the CategoryName.
This report lists the products in the selected category, and summarizes the number of products.
This section uses Label controls, Line controls and a TextBox. DataField property of txtCategory TextBox is set to CategoryName. Two Line controls and three Label controls create the report title and the column headers for this report.