Search code examples
c#comboboxfinditems

How do I find an item by value in an combobox in C#?


In C#, I have variable, a, of type string.

How do I find item by value of a in combobox (I want find item with value no display text of combobox).


Solution

  • You can find it by using the following code.

    int index = comboBox1.Items.IndexOf(a);
    

    To get the item itself, write:

    comboBox1.Items[index];