如何获取ListBox中项目的索引号?

时间:2016-03-02 16:42:02

标签: c# listbox

这是我的代码:

foreach(var item in listBox1.Items)
{
    string i = item.ToString();
    if (item.ToString()== "myItem")
    {
        label1.Text = i.ToString(); // how to get the founded item index?
        break; 
    }    
}

ListBox中有一个循环用于查找特定项目。找到该项后,我想知道ListBox中该项的索引是什么?

0 个答案:

没有答案