vb.net – 如何检查列表框中选定项目中的某些特定单词?

我试过了:

>如果ListBox1.Items.Contains(“myword”)那么
>如果ListBox1.SelectedIndex = ListBox1.Items.IndexOf(“myword”)则
>如果ListBox1.SelectedItems.Item(“myword”)那么

但没有效果.

最佳答案 尝试这样的事情,
listbox.items物业是
ListBox.ObjectCollection

For Each i As Object In ListBox1.SelectedItems
    If CStr(i).Contains("myword") Then
        BackColor = Color.Blue ' Do your logic here, I just used setting the BackColor for a test
    End If
Next
点赞