How To Change The Combobox Index To Match A Target String


string temp = "item1";


I need to select “Item1” from the combo box. In other words, I need to select the index that matches the string in the “temp” variable and select that index.


int targetIndex = combobox1.FindString(temp); combobox1.selectedIndex =


The FindString looks for a substring. If you need to perform an exact comparison then use Combobox.FindStringExact() Both these functions has
overloads where you can pass an integer second parameter to tell if you want the search to start from a different index than the usual 0.

The Search is NOT case sensitive on either of these functions.

In earlier versions of .net framework these are called “FindString” and “FindStringExact”.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: