-- 窗口下加载树,子表不能与父表同步加载,表格形式的加载树又可以。
我用表格形式时,可以实现子表与父表同步加载,用窗口加载树时,子表不能与父表同步加载,请教各位老师。
项目的BeforeLoadInnerTable事件
If e.DataTableName = "S征地记录" Then
e.Filter = "[_Identify] Is Null"
End If
项目的LoadUserSetting事件
If User.Name = "开发者" Or User.Name = "管理员" Then
DataTables("S征地记录").LoadFilter = ""
Else
DataTables("S征地记录").LoadFilter = "乡 = \'" & User.Name & "\' or 县 = \'" & User.Name & "\' or 项目名称 = \'" & User.Name & "\'"
End If
DataTables("S征地记录").Load()
父表"S征地记录"的AfterLoad事件
e.DataTable.LoadChildren("S征地明细")
窗口的AfterLoad事件
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree("S征地记录", "项目名称|县|乡")
trv.Nodes.Insert("显示所有行",0)
目录树的Dim Filter As String事件
Dim dr As DataRow = e.Node.DataRow \'获取生成此节点的行
If e.Node.Text <> "显示所有行" Then
Select Case e.Node.Level
Case 0
Filter = "[项目名称] = \'" & dr("项目名称") & "\'"
Case 1
Filter = "[项目名称] = \'" & dr("项目名称") & "\' And [县] = \'" & dr("县") & "\'"
Case 2
Filter = "[项目名称] = \'" & dr("项目名称") & "\' And [县] = \'" & dr("县") & "\' And [乡] = \'" & dr("乡") & "\'"
End Select
End If
Tables("S征地记录").Filter = Filter
Dim Filter As String
Dim dr As DataRow = e.Node.DataRow \'获取生成此节点的行
If e.Node.Text <> "显示所有行" Then
Select Case e.Node.Level
Case 0
Filter = "[项目名称] = \'" & dr("项目名称") & "\'"
Case 1
Filter = "[项目名称] = \'" & dr("项目名称") & "\' And [县] = \'" & dr("县") & "\'"
Case 2
Filter = "[项目名称] = \'" & dr("项目名称") & "\' And [县] = \'" & dr("县") & "\' And [乡] = \'" & dr("乡") & "\'"
End Select
End If
Tables("S征地记录").Filter = Filter