[]
To populate the C1ComboBox with data once a specific item in the combo box has been selected, use the SelectedItemChanged event like the following:
Add two C1ComboBoxes on the Form.
Add the string, "Pittsburgh", to the first C1ComboBox using the String Collection Editor.
Double click on the SelectedItemChanged event in C1ComboBox Properties window to create an event handler for the SelectedItemChanged event.
Add the following code to the SelectedIndexChanged event:
To write code in Visual Basic
Private Sub comboBox1_SelectedItemChanged(sender As Object, e As EventArgs)
c1ComboBox2.Items.Clear()
If c1ComboBox1.SelectedItem.ToString() = "Pittsburgh" Then
c1ComboBox2.Items.Add("Pittsburgh is known as the Steel City and the City of Bridges.")
c1ComboBox2.Items.Add("Pittsburgh has 446 Bridges")
Else
c1ComboBox2.Items.Add("You did not select Pittsburgh.")
End If
End Sub
To write code in C#
private void comboBox1_SelectedItemChanged(object sender, EventArgs e)
{
c1ComboBox2.Items.Clear();
if (c1ComboBox1.SelectedItem.ToString() == "Pittsburgh")
{
c1ComboBox2.Items.Add("Pittsburgh is known as the Steel City and the City of Bridges.");
c1ComboBox2.Items.Add("Pittsburgh has 446 Bridges");
}
else
{
c1ComboBox2.Items.Add("You did not select Pittsburgh.");
}
}
Run your project and select Pittsburgh in the first C1ComboBox.
Click on the dropdown button in the second C1ComboBox and notice the items were added to the dropdownlist based on what you added in the SelectedItemChanged event.
Populating C1Combbox with Data Using the SelectedIndexChanged Event