9

my

MessageBox.Show(listbox.Items[0].ToString());

is

"abber"

how can I find listbox item index 0 with "abber"?

nazim corakli
  • 197
  • 1
  • 3
  • 8

2 Answers2

19

With listbox.Items.IndexOf("abber")

That is:

int curIndex = listbox.Items.IndexOf("abber");
if(curIndex >= 0)
{
    MessageBox.Show(listbox.Items[curIndex].ToString());
}
varocarbas
  • 12,354
  • 4
  • 26
  • 37
5
 int index = listBox1.Items.IndexOf("Specify string here");
Abin
  • 2,868
  • 1
  • 23
  • 59