9

我的

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

"abber"

如何使用“abber”找到列表框项索引 0?

4

2 回答 2

19

listbox.Items.IndexOf("abber")

那是:

int curIndex = listbox.Items.IndexOf("abber");
if(curIndex >= 0)
{
    MessageBox.Show(listbox.Items[curIndex].ToString());
}
于 2013-07-12T09:25:10.353 回答
5
 int index = listBox1.Items.IndexOf("Specify string here");
于 2013-07-12T09:29:28.850 回答