以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  目录树  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=94120)

--  作者:刘林
--  发布时间:2016/12/15 21:55:00
--  目录树
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
DataTables("成绩").LoadFilter = Flt
DataTables("成绩").Load()

各节点均不勾选时,应是不加载,但成了加载所有数据了,请问如何改,一直没懂起,请老师指导

--  作者:有点蓝
--  发布时间:2016/12/15 21:58:00
--  
......

If Flt > "" Then
    DataTables("成绩").LoadFilter = Flt
Else
    DataTables("成绩").LoadFilter = "1=2"
End If
DataTables("成绩").Load()

--  作者:刘林
--  发布时间:2016/12/16 9:04:00
--  
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
Dim schoolName As String = user.group
DataTables("成绩").LoadFilter = "(" & Flt & ") and [_Locked] = 0 And 单位名称 = \'" & schoolname & "\'"
DataTables("成绩").Load()
Tables("成绩").sort = "考试名称,年级代码,考号"


老师,我选择这种方式,但当点去所有勾选时提示  \')\' 附近有语法错误。   没看出来

--  作者:有点色
--  发布时间:2016/12/16 9:11:00
--  

 要单独判断 【所有】 节点。

 

 If e.Node.Text = "所有" Then

  

 else

   

 End If


--  作者:刘林
--  发布时间:2016/12/16 16:05:00
--  
老师,什么意思,没懂起,怎么改
--  作者:有点色
--  发布时间:2016/12/16 16:38:00
--  

 

[此贴子已经被作者于2016/12/16 16:40:47编辑过]

--  作者:有点色
--  发布时间:2016/12/16 16:41:00
--  

或者这样

 

Dim nms As String() = {"单位名称","考试名称","年级代码","班级"} \'指定生成目录树的各列
Dim qts As String() = {"\'","\'","\'","\'"} \'指定将各列的值括起来的符号,这里都是字符型,所以都是单引号
Dim trv As WinForm.TreeView = e.Sender
Dim flt As String = ""
If e.node.text = "所有勾选" Then
    flt = "1=1"
Else
    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 andalso nd.text <> "所有勾选" 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
End If
Dim schoolName As String = user.group
DataTables("成绩").LoadFilter = "(" & Flt & ") and [_Locked] = 0 And 单位名称 = \'" & schoolname & "\'"
DataTables("成绩").Load()
Tables("成绩").sort = "考试名称,年级代码,考号"


--  作者:刘林
--  发布时间:2016/12/19 21:49:00
--  
没懂起“所有勾“选是指什么?
--  作者:有点蓝
--  发布时间:2016/12/19 22:01:00
--  
生成目录树的时候是不是增加了一个“显示全部”的节点

If e.node.text = "显示全部" Then