To populate the C1ComboBox with data once a specific item in the combo box has been selected, use the SelectedItemChanged event like the following:
To write code in Visual Basic
Visual Basic Copy CodePrivate 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")
Elsec1ComboBox2.Items.Add("You did not select Pittsburgh.")
End If
End Sub
To write code in C#
C# Copy Codeprivate 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.");
}
}