itm(0).Text is wrong, the correct is itm.Text
Also, you should add
vb Code:
rtb1.Text = System.IO.File.ReadAllText(IO.Path.Combine(scriptPath, itm(0).Text))
after
vb Code:
If Not itm Is Nothing Then
just in case .FindItemWithText(txtSearch.Text, True, 0, True) returns nothing
Try this new one
vb Code:
Private Sub txtSearch_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSearch.TextChanged
' Dim selArray As ListView.SelectedListViewItemCollection = ListView1.SelectedItems
' If selArray.Count > 0 Then
ListView1.Items.Clear()
Dim itm As ListViewItem
Dim i As Integer
For i = 0 To ListView1.Items.Count - 1
ListView1.Items.Item(i).BackColor = Color.White
ListView1.Items.Item(i).ForeColor = Color.Black
Next
With ListView1
itm = .FindItemWithText(txtSearch.Text, True, 0, True)
'tell me what im going to do in this line for searching that kind of method
If itm IsNot Nothing Then
rtb1.Text = System.IO.File.ReadAllText(IO.Path.Combine(scriptPath, itm.Text))
.Items.Item(itm.Index).EnsureVisible()
.Items.Item(itm.Index).BackColor = Color.CornflowerBlue
.Items.Item(itm.Index).ForeColor = Color.White
.Items.Item(itm.Index).Selected = True
Else
MsgBox("No Record Found!")
For i = 0 To ListView1.Items.Count - 1
ListView1.Items.Item(i).BackColor = Color.White
ListView1.Items.Item(i).ForeColor = Color.Black
Next
.Items(0).EnsureVisible()
.Items.Item(0).BackColor = Color.CornflowerBlue
.Items.Item(0).ForeColor = Color.White
.Items.Item(0).Selected = True
txtSearch.SelectionStart = 0
txtSearch.SelectionLength = Len(txtSearch.Text)
txtSearch.Focus()
End If
' End if
End With
itm = Nothing
End Sub