Step 3: Binding a ListBox to the DataSet
In This Topic
To make the chart data more readable, a listbox is required to be added to filter the categories from the data.
Perform the following steps to filter the categories from the data:
- From the Visual Studio Toolbox, double-click the ListBox control to add it to the form.
- Dock the ListBox control to the left of the FlexChart control so it appears like the following:
<IMAGE>
- Select the ListBox control, and then click on its smart tag.
- Select Use Data Bound items.
- In the Data Source drop-down listbox, select Categories from Other Data Sources>Project Data Sources>categoriesDataSet.
<IMAGE>
- Select CategoryName in the Display Member drop-down listbox.
- Double-click on the ListBox control to generate a listbox1_SelectedIndexChanged event.
- Add the following code in the listbox1_SelectedIndexChanged event to filter the CategoryID to the listbox when the user selects a category item:
Title Text |
Copy Code
|
Type your code here. |
- In the Form1_Load event, add the following code to force the new calculation after the refill so the first category of product items, Beverages, appears rather than all of the unfiltered categories:
Title Text |
Copy Code
|
Type your code here. |
- Run the application and select a category from the listbox to observe the chart filter the data.
The listbox is bound to the dataset successfully, as shown below:
<IMAGE>