ComboBox.SelectedIndex ComboBox.SelectedIndex ComboBox.SelectedIndex ComboBox.SelectedIndex Property


Gets or sets the index specifying the currently selected item.

 virtual property int SelectedIndex { int get(); void set(int value); };
public override int SelectedIndex { get; set; }
member this.SelectedIndex : int with get, set
Public Overrides Property SelectedIndex As Integer

Property Value

A zero-based index of the currently selected item. A value of negative one (-1) is returned if no item is selected.


The specified index is less than or equal to -2.


The specified index is greater than or equal to the number of items in the combo box.


The following code example show how to use the FindString method and SelectedIndex property. The example is part of a complete example in the ComboBox class overview.

void findButton_Click( Object^ sender, System::EventArgs^ e )
   int index = comboBox1->FindString( textBox2->Text );
   comboBox1->SelectedIndex = index;
private void findButton_Click(object sender, System.EventArgs e) {
    int index = comboBox1.FindString(textBox2.Text);
    comboBox1.SelectedIndex = index;
Private Sub findButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim index As Integer
    index = comboBox1.FindString(textBox2.Text)
    comboBox1.SelectedIndex = index
End Sub


This property indicates the zero-based index of the currently selected item in the combo box list. Setting a new index raises the SelectedIndexChanged event.

SelectedIndex, SelectedValue, and FormattingEnabled are related as follows:


To deselect the currently selected item, set the SelectedIndex to -1. You cannot set the SelectedIndex of a ComboBox item to -1 if the item is a data-bound item.

Applies to

See also