以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]筛选树的反选方法  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=119043)

--  作者:81538475
--  发布时间:2018/5/16 17:11:00
--  [求助]筛选树的反选方法
能够加个按钮,实现反选的效果吗,或者双击节点,实现反选。
图片点击可在新窗口打开查看此主题相关图片如下:反选.png
图片点击可在新窗口打开查看


Dim nms As String() = {"状态","部门"} \'指定生成目录树的各列 
Dim qts As String() = {"\'","\'","\'"} \'指定将各列的值括起来的符号,这里都是字符型,所以都是单引号 
Dim trv As WinForm.TreeView = e.Sender 
Dim flt As String 
Dim nd As WinForm.TreeNode 
For Each nd In e.node.allNodes \'清除子节点的选中标记 
    nd.Checked = False 
Next 
nd = e.Node.ParentNode 
Do While nd IsNot Nothing \'清除父节点的选中标记 
    nd.Checked = False 
    nd = nd.ParentNode 
Loop 
For Each nd In trv.AllNodes 
    If nd.Checked  Then 
        Dim rts() As String = nd.FullPath.Split("\\") 
        

        Dim val As String = ""
        For i As Integer = 0 To rts.length - 1
            If val > "" Then
                val = val & " And "
            End If
            val = val & nms(i) & " = " & qts(i) & rts(i) & qts(i)
   msgbox(nms(i))
        Next
        If flt > "" Then
            flt = flt & " Or (" & val & ")"
        Else
            flt = val
        End If
    End If
Next
Tables("人员信息表").Filter  = flt
[此贴子已经被作者于2018/5/16 17:43:34编辑过]

--  作者:有点甜
--  发布时间:2018/5/16 18:24:00
--  

Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
For Each nd As WinForm.TreeNode In trv.AllNodes
    nd.Checked = not nd.Checked
Next


--  作者:81538475
--  发布时间:2018/5/16 18:55:00
--  
反选实现了。但是没有应用到筛选上去。。而treeview里面的代码又不能放到 button里面去,应该如何处理呢
--  作者:有点甜
--  发布时间:2018/5/16 19:17:00
--  
Dim nms As String() = {"状态","部门"} \'指定生成目录树的各列
Dim qts As String() = {"\'","\'","\'"} \'指定将各列的值括起来的符号,这里都是字符型,所以都是单引号
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim flt As String = ""
For Each nd As WinForm.TreeNode In trv.AllNodes
    If nd.Checked  Then
        Dim rts() As String = nd.FullPath.Split("\\")
        Dim val As String = ""
        For i As Integer = 0 To rts.length - 1
            If val > "" Then
                val = val & " And "
            End If
            val = val & nms(i) & " = " & qts(i) & rts(i) & qts(i)
        Next
        If flt > "" Then
            flt = flt & " Or (" & val & ")"
        Else
            flt = val
        End If
    End If
Next
Tables("人员信息表").Filter  = flt

--  作者:81538475
--  发布时间:2018/5/16 23:26:00
--  
还是不行呀,麻烦帮忙看看吧
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.foxdb


--  作者:有点甜
--  发布时间:2018/5/16 23:44:00
--  

Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
For Each nd As WinForm.TreeNode In trv.AllNodes
    nd.Checked = not nd.Checked
Next
Dim nms As String() = {"产品","客户"} \'指定生成目录树的各列
Dim qts As String() = {"\'","\'"} \'指定将各列的值括起来的符号,这里都是字符型,所以都是单引号
Dim flt As String = ""
For Each nd As WinForm.TreeNode In trv.AllNodes
    If nd.Checked AndAlso nd.level = 1 Then
        Dim rts() As String = nd.FullPath.Split("\\")
        Dim val As String = ""
        For i As Integer = 0 To rts.length - 1
            If val > "" Then
                val = val & " And "
            End If
            val = val & nms(i) & " = " & qts(i) & rts(i) & qts(i)
        Next
        If flt > "" Then
            flt = flt & " Or (" & val & ")"
        Else
            flt = val
        End If
    End If
Next
Tables("订单").Filter  = flt


--  作者:81538475
--  发布时间:2018/5/17 9:39:00
--  
多谢了。另外请问下,能不能让双击节点的时候不会展开目录树呢。
--  作者:有点甜
--  发布时间:2018/5/17 10:18:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1 (2).foxdb