Foxtable(狐表)用户栏目专家坐堂 → 目录树定位


  共有4503人关注过本帖平板打印复制链接

主题:目录树定位

帅哥哟,离线,有人找我吗?
实话实说
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2649 积分:19384 威望:0 精华:1 注册:2008/9/12 9:19:00
目录树定位  发帖心情 Post By:2021/1/22 8:24:00 [只看该作者]

目录树内容太多,需要查找定位。以下代码可以按产品代码、型号、规格或型号规格模糊查找,但定位不准。我想分成2个按钮,一个按钮按代码定位,一个按钮型号或规格或型号规格定位。
?按钮的代码

图片点击可在新窗口打开查看此主题相关图片如下:snap1.jpg
图片点击可在新窗口打开查看
Dim arr() As String = e.Form.Controls("型号规格").text.split(" ")
Dim xh,gg As String
If arr.length > 0 Then
    xh = arr(0)
End If
If arr.Length > 1 Then
    gg = arr(1)
End If

Dim trv As WinForm.TreeView =  e.Form.Controls("产品目录")
Dim Start As Integer
Dim idx As Integer = - 1
If trv.SelectedNode IsNot Nothing Then '获取当前节点位置.
    Dim fullpath As String = trv.SelectedNode.FullPath
    For i As Integer = 0 To trv.AllNodes.count - 1
        If trv.AllNodes(i).fullpath = fullpath 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 gg > "" Then
        If nd.text.IndexOf(gg) >= 0 Then
            If xh > "" Then
                If nd.ParentNode.Text.IndexOf(xh) >= 0 Then
                    trv.SelectedNode = nd
                    nd.EnsureVisible
                    idx = i '将找到的位置复制给变量idx
                    Exit For
                End If
            Else
                trv.SelectedNode = nd
                nd.EnsureVisible
                idx = i '将找到的位置复制给变量idx
                Exit For
            End If
        End If
    Else
        If xh > "" Then
            If nd.Text.IndexOf(xh) >= 0 Then
                trv.SelectedNode = nd
                nd.EnsureVisible
                idx = i '将找到的位置复制给变量idx
                Exit For
            End If
        End If
        
    End If
Next
If idx = -1 Then
    msgbox("没找到或找完了")
End If
trv.Select()


 回到顶部
总数 44 1 2 3 4 5 下一页