To populate the C1ComboBox with data once a specific index in the combo box has been selected, use the SelectedIndexChanged event like the following:
To write code in Visual Basic
Title Text Copy CodePrivate Sub comboBox1_SelectedIndexChanged(sender As Object, e As EventArgs)
c1ComboBox2.Items.Clear()
If c1ComboBox1.SelectedIndex.ToString() = "1" Thenc1ComboBox2.Items.Add("You selected the second item.")
Elsec1ComboBox2.Items.Add("You did not select the second item.")
End If
End Sub
To write code in C#
C# Copy Codeprivate void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
c1ComboBox2.Items.Clear();
if (c1ComboBox1.SelectedIndex.ToString() == "1")
{
c1ComboBox2.Items.Add("You selected the second item.");
}
else
{
c1ComboBox2.Items.Add("You did not select the second item.");}
}