[]
        
(Showing Draft Content)

Populating C1Combbox with Data Using the SelectedIndexChanged Event

To populate the C1ComboBox with data once a specific index in the combo box has been selected, use the SelectedIndexChanged event like the following:

  1. Add two C1ComboBoxes on the Form.

  2. In the first C1ComboBox add the items line by line in the String Collection Editor so it appears like the following:

    stringcollectioneditor_combobox

  3. Double click on the SelectedIndexChanged event in the C1ComboBox Properties window to create an event handler for the SelectedIndexChanged event.

  4. Add the following code to the SelectedIndexChanged event:

To write code in Visual Basic

 Private Sub comboBox1_SelectedIndexChanged(sender As Object, e As EventArgs)
     c1ComboBox2.Items.Clear()
     If c1ComboBox1.SelectedIndex.ToString() = "1" Then
         c1ComboBox2.Items.Add("You selected the second item.")
     Else
         c1ComboBox2.Items.Add("You did not select the second item.")
     End If
 End Sub

To write code in C#

  private 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.");
             }
         }
  1. Run your project and select the first index or second item, "Orlando" in the first C1ComboBox.

  2. 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 SelectedIndexChanged event.

    combo-box

See Also

C1RangeSlider Control Overview