老师好!
我在主窗口类型中绑定了两个Normal表,订单和订单.订单明细, 两表建立了单向关联,窗口中加了一个TreeView,希望通过双击加载树各节点加载订单表,但是双击节点不能自动加载,请老师指导下,代码如下:
窗口AfterLoad:
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C
cmd.CommandText = "SELECT DISTINCT 大类自用,中类自用,小类自用,型号规格 F rom {订单}"
dt = cmd.ExecuteReader()
Dim trv As WinForm.TreeView = e.F orm.Controls("TreeView1")
trv.BuildTree(dt,"大类自用|中类自用|小类自用|型号规格")
trv.Nodes.Insert("加载所有数据",0)
加载树 NodeMouseDoubleClick:
Dim Filter As String
If e.node.Text = "加载所有数据" Then
Filter = ""
Else
Dim dr As DataRow = e.Node.DataRow '获取生成此节点的DataRow
Select Case e.Node.Level
Case 0
Filter ="[大类自用] = '" & dr("大类自用") & "'"
Case 1
Filter ="[大类自用] = '" & dr("大类自用") & "' And [中类自用] = '" & dr("中类自用") & "'"
Case 2
Filter ="[大类自用] = '" & dr("大类自用") & "' And [中类自用] = '" & dr("中类自用") & "'And [小类自用] = '" & dr("小类自用") & "'"
Case 3
Filter ="[大类自用] = '" & dr("大类自用") & "' And [中类自用] = '" & dr("中类自用") & "'And [小类自用] = '" & dr("小类自用") & "'And [型号规格] = '" & dr("型号规格") & "'"
End Select
End If
DataTables("订单").LoadFilter = Filter
DataTables("订单").Load()
外部数据表中订单表的过滤/排序 :
[_Identify] Is Null
[此贴子已经被作者于2020/5/26 9:48:30编辑过]