12-29-2011, 03:37 AM
I also have a predicate method, but this works well and should be easy to understand, for those of you who leech and probably don't understand this, well I hope it works for you lol, and to those that don't understand but want to know more about my code, just reply and i'll respond.
Code:
Public Class Form1
Public SearchText As String
Public _data() As String = {"1_one,1_two,1_three", "2_one,2_sdf,2_three", "3_one,3_sdf,3_three"}
Public Arr As New List(Of String)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Arr.AddRange(_data)
For Each obj As String In Arr
Dim Sdata() As String = obj.Split(","c)
Dim LVC As New ListViewItem(Sdata)
ListView1.Items.Add(LVC)
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SearchText = TextBox1.Text
Dim Arr_Modified As New List(Of String)
Arr_Modified.AddRange(Arr)
For Each ObjNewStr As String In Arr
'If not middle value in array contains search value
If Not ObjNewStr.Split(","c)(1).Contains(SearchText) Then
Arr_Modified.Remove(ObjNewStr)
End If
Next
ListView1.Items.Clear()
For Each ObjNewStr As String In Arr_Modified
Dim StrSplit() As String = ObjNewStr.Split(","c)
Dim Mod_LVC As New ListViewItem(StrSplit)
ListView1.Items.Add(Mod_LVC)
Next
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
SearchText = TextBox1.Text
Dim Arr_Modified As New List(Of String)
Arr_Modified.AddRange(Arr)
For Each ObjNewStr As String In Arr
'If not middle value in array contains search value
If Not ObjNewStr.Split(","c)(1).Contains(SearchText) Then
Arr_Modified.Remove(ObjNewStr)
End If
Next
ListView1.Items.Clear()
For Each ObjNewStr As String In Arr_Modified
Dim StrSplit() As String = ObjNewStr.Split(","c)
Dim Mod_LVC As New ListViewItem(StrSplit)
ListView1.Items.Add(Mod_LVC)
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
'Test Button for Debugging
End Sub
End Class