John Gates
John Gates

Reputation:

C#: How do you control the current item index that displays in a ComboBox?

I have set a list of items in a combobox, but when I debug the application, I have to select an item from the drop down to display an item by default. Is there a property? that you can set so that the combobox itemindex will always begin at 0 meaning the first item in the list at startup of the application?

Upvotes: 2

Views: 2986

Answers (2)

Josh Mein
Josh Mein

Reputation: 28645

You are gonna want to use the SelectedIndex attribute.

The SelectedItem property can only be read. Using the SelectedText and SelectedValue Properties will change the Text and Value not which one is selected

Upvotes: 2

BFree
BFree

Reputation: 103750

this.comboBox1.SelectedIndex = 0;

Upvotes: 2

Related Questions