To filter the categories from the data, complete the following steps:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub listBox1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles listBox1.SelectedIndexChanged If listBox1.SelectedIndex >= 0 Then Dim categoryID As String = Me.categoriesDataSet1.Categories(listBox1.SelectedIndex).CategoryID.ToString() Me.dataView1.RowFilter = "CategoryID = " + categoryID Me.c1Chart1.Header.Text = listBox1.Text End If End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e) { if (listBox1.SelectedIndex >= 0) { string categoryID = this.categoriesDataSet1.Categories[listBox1.SelectedIndex].CategoryID.ToString(); this.dataView1.RowFilter = "CategoryID = " + categoryID; this.c1Chart1.Header.Text = listBox1.Text; } } |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
'force the new calculation after the refill listBox1_SelectedIndexChanged(Me.listBox1, New EventArgs()) |
To write code in C#
C# |
Copy Code
|
---|---|
//force the new calcuation after the refill listBox1_SelectedIndexChanged(this.listBox1, new EventArgs()); |
Congratulations! You successfully bound data to the chart. In the next step you will modify the appearance of the chart.