原代码:
AfterLoad
Dim dr As DataRow
Dim tv As WinForm.TreeView
tv
=e.Form.Controls("学员列表树")
tv.BuildTree("考试数据表", "班代码|学号")
'tv.BuildTree("考试数据表",
"入学时间|校区|班名称中文|姓名")
'tv.BuildTree("考试数据表",
"入学时间|校区|班代码|学号")
For Each nd As WinForm.TreeNode In
tv.AllNodes
If nd.Level = 0 Then
nd.BackColor = Color.Gainsboro
dr = DataTables("考试数据表").find("班代码 =
'" & nd.Name & "'")
If dr IsNot Nothing Then
nd.text = dr("班名称中文")
End If
Else If nd.Level = 1
dr = DataTables("考试数据表").find("学号 = '" & nd.Name & "'")
If dr IsNot
Nothing Then
nd.text = dr("姓名")
End If
End If
Next
tv.Nodes.Insert("全部学员", "全部学员", 0)
For Each nd As WinForm.TreeNode In
tv.AllNodes
If nd.Name <> "全部学员" And nd.AllNodes.Count > 0 Then
nd.MoveRight
End If
Next
目录树AfterCheckNode代码
Dim nd,nd1 As WinForm.TreeNode
nd = e.node
If nd.Nodes.Count > 0
For Each nd1 In
nd.AllNodes
nd1.Checked = nd.Checked
Next
End If
If e.node.Checked = False
Do While
nd.parentnode IsNot Nothing
nd = nd.parentnode
If
nd.Nodes.Count > 0
For i As
Integer = 0 To nd.Nodes.Count -1
If
nd.Nodes(i).Checked = True
Exit Do
End If
If i =
nd.Nodes.Count -1
nd.Checked = False
End If
Next
End If
Loop
Else
Do While
nd.parentnode IsNot Nothing
nd = nd.parentnode
nd.Checked = True
Loop
End If
Dim bdm,xh,tj As String
Dim cnt,jds As Integer
For Each nd In e.Form.Controls("学员列表树").nodes("全部学员").AllNodes
If nd.Level = 1 And
nd.Checked = True
Then
bdm = nd.name
cnt = nd.AllNodes.Count
For Each
nd1 In
nd.AllNodes
If
nd1.Checked = True
xh = xh & "," & nd1.name
jds = jds +1
If jds =
cnt
xh = "all"
End If
Else
If xh
> ""
xh = xh.Replace("all","")
End If
End If
Next
If xh
> ""
xh = xh.Trim(",")
End If
jds = 0
tj = tj & "|"
& bdm & "\" & xh
If tj
> ""
tj = tj.Trim("|")
End If
End If
Next
Dim jztj As String
If tj > ""
e.Form.Controls("加载条件").text = tj.Replace("|",vbcrlf)
jztj = tj.Replace("|",vbcrlf)
Else
e.Form.Controls("加载条件").text = ""
End
If
想实现的效果
AfterLoad
Dim trv As
WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree("考试数据表", "入学时间|校区|班名称中文|姓名")'使用排序
trv.Nodes.Insert("全部学员", 0)
目录树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
Dim trv1 As
WinForm.TreeView = e.Form.Controls("TreeView1")
If e.Node.Name = "全部学员" Then
'
Tables("考试数据表").Filter = ""
Tables("考试数据表").Filter = flt
End If
For Each nd1 As
WinForm.TreeNode In e.Node.AllNodes '清除子节点的选中标记
nd1.Checked = e.Node.Checked
Next
Dim pd As WinForm.TreeNode = e.Node.ParentNode
If pd IsNot Nothing Then
Dim bb As Boolean = True
For Each nd2 As
WinForm.TreeNode In pd.Nodes
If
nd2.Checked = False
Then
bb = False
Exit For
End If
Next
pd.Checked = bb
End If
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
请教如何修改前面的代码?