c# - 如何找到具有项目值的列表框项目索引?

标签 c# windows-phone-7 listbox indexing

我的

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());
}

关于c# - 如何找到具有项目值的列表框项目索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17611537/

相关文章:

WPF 列表框固定宽度

c# - 如何根据 gridview 中的某些值更改标签的颜色

c# - 有没有一种方法可以防止 NHibernate LINQ 提供程序出现 bool 性能问题

c# - Windows Phone 中的 MessageBoxButtons 成员

c# - 如何获得内部带有矩形的 ScrollViewer 以在到达矩形末端时停止滚动?

c# - 如何在不使用 "Contains"的情况下从列表框中删除项目?

c# - Windows Phone 8中BitmapImage/Image控件的内存消耗

c# - a = (x == null) 的最佳语法?空 : x. 函数()

.net - 添加后,Windows Phone MVVM 中 ListBox DataBound 到 ObservableCollection 不会更新

c# - 在绑定(bind)时更改 ListBox 的特定项目背景颜色