以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  多种 筛选模式  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=113679)

--  作者:yifan3429
--  发布时间:2018/1/20 20:19:00
--  多种 筛选模式
e.Form.Controls("TreeView2").BuildTree("订单清单", "楼层|房间|类别|产品名")
e.Form.Controls("TreeView2").BuildTree("订单清单", "房间|楼层|类别|产品名")
e.Form.Controls("TreeView2").BuildTree("订单清单", "产品名|房间")
e.Form.Controls("TreeView2").BuildTree("订单清单", "类别|楼层|房间|产品名")
四种情况筛选模式

AfterCheckNode

代码入下 

勾选复选框会不正常

如何改变呢


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)
        Next
        If flt > "" Then
            flt = flt & " Or (" & val & ")"
        Else
            flt = val
        End If
    End If
Next
Tables("订单总表.订单清单").Filter  = flt

--  作者:有点甜
--  发布时间:2018/1/21 22:50:00
--  
根据不同的目录树生成对应的变量
 
vars("nms") = new string(){"楼层","房间","产品名","类别"} \'指定生成目录树的各列
vars("nms") = new string(){"\'","\'","\'","\'"} \'指定将各列的值括起来的符号,这里都是字符型,所以都是单引号
 
然后,AfterCheckNode事件代码,这样写
 
Dim nms As String() = vars("nms")
Dim qts As String() = vars("qts")
 
 
 

--  作者:yifan3429
--  发布时间:2018/1/22 12:52:00
--  
 原始的菜单代码入下
Case "按楼层"
   e.Form.Controls("TreeView2").BuildTree("订单清单", "楼层|房间|类别|产品名")

下面的代码是替换这个吗  怎么变更替换呢

vars("nms") = new String(){"楼层","房间","产品名","类别"} \'指定生成目录树的各列
vars("nms") = new String(){"\'","\'","\'","\'"} \'指定将各列的值括起来的符号,这里都是字符型,所以都是单引号

AfterCheckNode


Dim nms As String() = vars("nms")

Dim qts As String() = vars("qts")
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)
        Next
        If flt > "" Then
            flt = flt & " Or (" & val & ")"
        Else
            flt = val
        End If
    End If
Next
Tables("订单总表.订单清单").Filter  = flt

--  作者:有点甜
--  发布时间:2018/1/22 15:19:00
--  

改成

 

Case "按楼层"
    e.Form.Controls("TreeView2").BuildTree("订单清单", "楼层|房间|类别|产品名")
    vars("nms") = new String(){"楼层", "房间", "类别", "产品名"} \'指定生成目录树的各列
    vars("qts") = new String(){"\'","\'","\'","\'"} \'指定将各列的值括起来的符号,这里都是字符型,所以都是单引号
[此贴子已经被作者于2018/1/22 15:19:19编辑过]