1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
TextBox1.Text = TextBox1.Text.Replace(" ", "")
Dim count As Integer = 0
Dim mark As Integer
Dim str As String
For index As Integer = ListView1.Items.Count - 1 To 0 Step -1
If TextBox1.Text = "" Then
ListView1.Items(index).SubItems(1).ForeColor = Color.Red
Else
If Microsoft.VisualBasic.Left(ListView1.Items(index).SubItems(1).Text, TextBox1.Text.Length) = TextBox1.Text Then
ListView1.Items(index).SubItems(1).ForeColor = Color.Red
mark = index
count += 1
Else
ListView1.Items(index).SubItems(1).ForeColor = Color.Transparent
End If
End If
Next
If count = 0 Then
If Not flagfound Then
flagmark = mark
End If
flagfound = True
str = ListView1.Items(mark).SubItems(1).Text
ListView1.Items.RemoveAt(mark)
ListView1.Items.Insert(0, str)
End If
If DirectCast(sender, TextBox).Text = String.Empty AndAlso flagfound Then
For i = 0 To ListView1.Items.Count - 1
str = ListView1.Items(i).SubItems(1).Text
ListView1.Items(i).SubItems(0).Text = ListView1.Items.Item(i).SubItems(1).Text
ListView1.Items.Insert(flagmark, str)
flagfound = False
Next i
End If
End Sub |