# Populating C1Combbox with Data Using the SelectedIndexChanged Event

This topic throws light on populating C1Combbox with data using the SelectedIndexChanged event.

## Content

To populate the C1ComboBox with data once a specific index in the combo box has been selected, use the [SelectedIndexChanged](/componentone/api/win/online-input/dotnet-framework-api/C1.Win.C1Input.4.8/C1.Win.C1Input.C1ComboBox.SelectedIndexChanged.html) 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](https://cdn.mescius.io/document-site-files/images/6c2f30e9-4d3a-4f86-b649-ecbef777b3a3/images/stringcollectioneditor_combobox.png)
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:

DOC-DETAILS-TAG-OPEN
DOC-SUMMARY-TAG-OPEN
To write code in Visual Basic
DOC-SUMMARY-TAG-CLOSE

```vbnet
 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
```

DOC-DETAILS-TAG-CLOSE
DOC-DETAILS-TAG-OPEN
DOC-SUMMARY-TAG-OPEN
To write code in C#
DOC-SUMMARY-TAG-CLOSE

```csharp
  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.");
             }
         }
```

DOC-DETAILS-TAG-CLOSE

4. Run your project and select the first index or second item, "Orlando" in the first C1ComboBox.
5. 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](https://cdn.mescius.io/document-site-files/images/6c2f30e9-4d3a-4f86-b649-ecbef777b3a3/images/combobox_selectedindex.png)

## See Also

[C1RangeSlider Control Overview](/componentone/docs/win/online-input/usingthec1inputcontr/c1inputcontrols/C1RangeSliderControlOverview)