我的代码如下:Dim gjc As String = e.Form.Controls("cplb").text
If gjc = "" Then
Return
End If
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim start As Integer
Dim idx As Integer = -1
If trv.SelectedNode IsNot Nothing Then
Dim ljmc As String = trv.SelectedNode.FullName
For i As Integer = 0 To trv.AllNodes.Count - 1
If trv.AllNodes(i).FullName = ljmc Then
start = i '找出当前目录节点的顺序值
Exit For
End If
Next
End If
For i As Integer = start + 1 To trv.AllNodes.Count - 1
Dim jd As WinForm.TreeNode = trv.AllNodes(i)
If jd.Text.IndexOf(gjc) > 0 Then
trv.SelectedNode = jd
jd.EnsureVisible
idx = i
Exit For
End If
Next
If idx = -1 Then 'idx是初始值就是没有找到,那么从第一个开始再找一次
For i As Integer = 0 To trv.AllNodes.Count - 1
Dim jd As WinForm.TreeNode = trv.AllNodes(i)
If jd.Text.IndexOf(gjc) > 0 Then
trv.SelectedNode = jd
jd.EnsureVisible
Exit For
End If
Next
End If
trv.Select()
这段代码,如果有1个节点名称叫“ABCDEFG”,如果搜索“ABC”是没问题的,但搜索“ABCDEF”却搜不到。
这是什么原因,老师能帮忙找找原因吗?我自己已经看不懂了