-- 作者:大红袍
-- 发布时间:2016/5/20 15:30:00
--
Dim txt As String = e.Form.controls("TextBox1").Text If txt = "" 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 FullName As String = trv.SelectedNode.FullName For i As Integer = 0 To trv.AllNodes.count - 1 If trv.AllNodes(i).FullName = FullName Then Start = i Exit For End If Next End If For i As Integer = Start + 1 To trv.AllNodes.count - 1 \'从当前节点的下一个节点开始查找 Dim nd As WinForm.TreeNode = trv.AllNodes(i) If nd.Text.IndexOf(txt) >= 0 Then trv.SelectedNode = nd nd.EnsureVisible idx = i \'将找到的位置复制给变量idx Exit For End If Next If idx = -1 Then \'idx的值如果等于初始值-1,表示没有找到下一个符合条件的节点,那么从第一个节点开始重新查找. For i As Integer = 0 To Start - 1 Dim nd As WinForm.TreeNode = trv.AllNodes(i) If nd.Text.IndexOf(txt) >= 0 Then trv.SelectedNode = nd nd.EnsureVisible Exit For End If Next End If trv.Select()
http://www.foxtable.com/help/topics/2961.htm
|