Foxtable(狐表)用户栏目专家坐堂 → [求助]树节点的检索


  共有2561人关注过本帖树形打印复制链接

主题:[求助]树节点的检索

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


加好友 发短信
等级:超级版主 帖子:109678 积分:558082 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/4/25 16:38:00 [显示全部帖子]

Dim tv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim pn As WinForm.TreeNode = vars("pn")
vars("F") = False
For Each nd As WinForm.TreeNode In tv.AllNodes

    If vars("F") = False
        If pn Is Nothing
            vars("F") = True
        ElseIf pn.Text = nd.Text 
            vars("F") = True
            Continue For
        End If
    End If
    If vars("F") AndAlso nd.Text.Contains( txt)Then
        tv.SelectedNode = nd
        vars("pn") = nd
        nd.EnsureVisible
        Exit For
    End If
Next

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:109678 积分:558082 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/4/26 11:22:00 [显示全部帖子]

keydown事件加上:e.cancel = true

fullname这个实际测试一下不就知道了。我们给只是一个参考,细节的东西自己补充测试

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:109678 积分:558082 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/4/26 13:59:00 [显示全部帖子]

Dim tv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim txt As String = e.Sender.Text
e.Cancel = True
If tv.AllNodes.Count > 0 AndAlso e.KeyCode = Keys.Enter Then
    Dim pn As WinForm.TreeNode = vars("pn")
    vars("F") = False
    For Each nd As WinForm.TreeNode In tv.AllNodes
        If vars("F") = False
            If pn Is Nothing
                vars("F") = True
            ElseIf pn.FullName = nd.FullName
                vars("F") = True
                Continue For
            End If
        End If

        If vars("F") = True AndAlso nd.Text.Contains(txt) = True Then
            tv.SelectedNode = nd
            vars("pn") = nd
            nd.EnsureVisible
            Return
        End If
    Next
    vars("pn") = Nothing
End If

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:109678 积分:558082 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/4/26 22:02:00 [显示全部帖子]

dim e = args(0)
Dim tv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim txt As String = e.Sender.Text
e.Cancel = True
If tv.AllNodes.Count > 0 AndAlso e.KeyCode = Keys.Enter Then
    Dim pn As WinForm.TreeNode = vars("pn")
    vars("F") = False
    For Each nd As WinForm.TreeNode In tv.AllNodes
        If vars("F") = False
            If pn Is Nothing
                vars("F") = True
            ElseIf pn.FullName = nd.FullName
                vars("F") = True
                Continue For
            End If
        End If

        If vars("F") = True AndAlso nd.Text.Contains(txt) = True Then
            tv.SelectedNode = nd
            vars("pn") = nd
            nd.EnsureVisible
            Return ""
        End If
    Next
    vars("pn") = Nothing
End If

Functions.Execute("某函数",e)

 回到顶部