How to search through all items of a combobox in C#?

cabral_007 picture cabral_007 · Aug 26, 2013 · Viewed 60.4k times · Source

I have a combobox, and I would like to search through every element in it.

How can I do this? (also the number of items is not the same everytime, but this is not so important).

I am using c# windows form application.

Answer

Ehsan picture Ehsan · Aug 26, 2013

you can do this

for (int i = 0; i < myComboBox.Items.Count; i++)
{
     string value = myComboBox.GetItemText(myComboBox.Items[i]); 
}