Unfortunately, there is no easy method to use for this. The Contains and ContainsKey (or even Find) methods do not search the listview for a given string. However, you can roll your own as follows:
Private Function InListView(lvw, text) As Boolean
For Each item As ListViewItem In lvw.items
If item.Text = text Then Return True
Next
Return False
End Function
If you pass this function a listview control and a string it will return True if that string appears in any cell in the first column, False otherwise. For example
Dim found As Boolean = InListView(MyListView, "Buffalo")
Reverend Jim
Illigitimae non carborundum
3,748 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33
I dont get your point. What would you like to do exactly? Tell us the pattern why not adding a Beef as well?
Mitja Bonca
Posting Maven
2,561 posts since May 2009
Reputation Points: 642
Solved Threads: 486
Skill Endorsements: 15
I think the OP is saying that if (for example) Buffalo has already been added to the listview then it should not be added again.
Reverend Jim
Illigitimae non carborundum
3,748 posts since Aug 2010
Reputation Points: 585
Solved Threads: 470
Skill Endorsements: 33
Question Answered as of 1 Year Ago by
Reverend Jim,
poojavb
and
Mitja Bonca