15-01-17, 03:57 AM
vb.net
كيف يتم البحث فى ليست فيو موجودة فى فورم اخر
لدى فنشكن للبحث ويبحث بنجاح فى نفس الفورم ولكن مش شغال عند البحث من فورم اخر
الكود
Public Sub SearchTextInListView(ByVal text As String, ByVal lstSource As ListView, Optional ByVal SubItemsN As Integer = 0)
Static unList As New ListView
Static lastRearch As String = ""
Dim item1 As ListViewItem = Nothing
If lastRearch = text Then
Return
Else
lastRearch = text
End If
Dim Index As Integer = 0
While Index < lstSource.Items.Count
lstSource.Invoke(Sub() item1 = lstSource.Items(Index))
If item1.SubItems(SubItemsN).Text.ToLower().Contains(text.ToLower()) = False Then
Index -= 1
'lstSource.Invoke(Sub() lstSource.Items.Remove(item))
lstSource.Invoke(Sub()
lstSource.BeginUpdate()
lstSource.Items.Remove(item1)
lstSource.EndUpdate()
End Sub)
If unList.Items.Contains(item1) = False Then
unList.Items.Add(item1)
End If
End If
Index += 1
End While
Dim index2 As Integer = 0
Dim cItem As ListViewItem
While index2 < unList.Items.Count
cItem = unList.Items(index2)
If cItem.SubItems(SubItemsN).Text.ToLower().Contains(text.ToLower()) Then
index2 -= 1
unList.Items.Remove(cItem)
'lstSource.Invoke(Sub() lstSource.Items.Add(cItem))
lstSource.Invoke(Sub()
lstSource.BeginUpdate()
lstSource.Items.Add(cItem)
lstSource.EndUpdate()
End Sub)
End If
index2 += 1
End While
End Sub
كيف يتم البحث فى ليست فيو موجودة فى فورم اخر
لدى فنشكن للبحث ويبحث بنجاح فى نفس الفورم ولكن مش شغال عند البحث من فورم اخر
الكود
Public Sub SearchTextInListView(ByVal text As String, ByVal lstSource As ListView, Optional ByVal SubItemsN As Integer = 0)
Static unList As New ListView
Static lastRearch As String = ""
Dim item1 As ListViewItem = Nothing
If lastRearch = text Then
Return
Else
lastRearch = text
End If
Dim Index As Integer = 0
While Index < lstSource.Items.Count
lstSource.Invoke(Sub() item1 = lstSource.Items(Index))
If item1.SubItems(SubItemsN).Text.ToLower().Contains(text.ToLower()) = False Then
Index -= 1
'lstSource.Invoke(Sub() lstSource.Items.Remove(item))
lstSource.Invoke(Sub()
lstSource.BeginUpdate()
lstSource.Items.Remove(item1)
lstSource.EndUpdate()
End Sub)
If unList.Items.Contains(item1) = False Then
unList.Items.Add(item1)
End If
End If
Index += 1
End While
Dim index2 As Integer = 0
Dim cItem As ListViewItem
While index2 < unList.Items.Count
cItem = unList.Items(index2)
If cItem.SubItems(SubItemsN).Text.ToLower().Contains(text.ToLower()) Then
index2 -= 1
unList.Items.Remove(cItem)
'lstSource.Invoke(Sub() lstSource.Items.Add(cItem))
lstSource.Invoke(Sub()
lstSource.BeginUpdate()
lstSource.Items.Add(cItem)
lstSource.EndUpdate()
End Sub)
End If
index2 += 1
End While
End Sub