Searching ListView2 for string and removing
Trying to figure out how to find the text that is typed in "SeedKW text" and when Cmd button i clicked, it removes that text from "SeedKW text" from listview2
vb Code:
Dim srt As String = "Searches related to " & SeedKW.Text
For Each srtItem As ListViewItem In ListView2.Items
If srtItem.SubItems.Item(0).Text = srt Then
MsgBox(srt)
End If
Next
I Would like to have it search for a partial string like and removing everything from listview one that contains "Searches related to" is that's possible.
Re: Searching ListView2 for string and removing
Strings have a StartsWith method that you could use to identify partial strings:-
vbnet Code:
'
Dim strn As String = "ABC 123"
If strn.StartsWith("ABC") Then MsgBox("YES!!!")
Re: Searching ListView2 for string and removing
Quote:
Originally Posted by
Niya
Strings have a
StartsWith method that you could use to identify partial strings:-
vbnet Code:
'
Dim strn As String = "ABC 123"
If strn.StartsWith("ABC") Then MsgBox("YES!!!")
Thank you, this is what i came up with from your code.
VB.NET Code:
For Each srt As ListViewItem In ListView2.Items
If srt.SubItems(0).Text.StartsWith("Searches related to") Then
ListView2.Items.Remove(srt)
End If
Next
Re: Searching ListView2 for string and removing
Quote:
Originally Posted by
Niya
Strings have a
StartsWith method that you could use to identify partial strings:-
vbnet Code:
'
Dim strn As String = "ABC 123"
If strn.StartsWith("ABC") Then MsgBox("YES!!!")
Thank you, this is what i came up with
VB.NET Code:
For Each srt As ListViewItem In ListView2.Items
If srt.SubItems(0).Text.StartsWith("Searches related to") Then
ListView2.Items.Remove(srt)
End If
Next