AsifRehmani
AsifRehmani

Reputation: 25

C# Compare Combobox Member Value with string

I want to compare the string with Combobox Member Values. If string value matched, I need the index of matched value as well.

Upvotes: 0

Views: 269

Answers (1)

possibly this will help you.

private void SampleMethod()
{
    cboExample.Items.AddRange(new string[]
    {
        "Element 1", "Element 2", "Element 3", "Element 4"
    });

    string searchedText = "Element 3";
    int index = cboExample.FindString(searchedText);
    MessageBox.Show($"Index of \"{searchedText}\" is {index}");
}

Upvotes: 1

Related Questions