如何找到具有项目值的列表框项目索引?
我的
MessageBox.Show(listbox.Items[0].ToString());
是
"abber"
如何找到带有“abber”的列表框项索引0?
使用listbox.Items.IndexOf("abber")
那是:
int curIndex = listbox.Items.IndexOf("abber"); if(curIndex >= 0) { MessageBox.Show(listbox.Items[curIndex].ToString()); }
int index = listBox1.Items.IndexOf("Specify string here");