以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 如何通过临时表生成目录树并进行选择 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=123433) |
||||
-- 作者:ZJZK2018 -- 发布时间:2018/8/14 16:49:00 -- 如何通过临时表生成目录树并进行选择 1、AfterLoad事件中 Dim dt As DataTable Dim jb As New SQLJoinTableBuilder("查询表1","招标信息") jb.AddTable("招标信息","项目编号","标录信息","项目编号") jb.AddCols("{标录信息}.项目编号","{招标信息}.项目名称","咨询类型","归属部门","投标地区") dt = jb.Build(True) \'参数设置为True,生成一个临时表,不在主界面显示 \'然后根据统计表生成目录树 Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildTree(dt,"咨询类型|归属部门|投标地区") trv.Nodes.Insert("显示所有行",0) 2、 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("标录信息_table1").Filter = flt 我的需求是:通过生成临时表"查询表1",并生成目录树,根据“项目编号”列进行筛选?如何调整?
[此贴子已经被作者于2018/8/14 16:54:20编辑过]
|
||||
-- 作者:有点甜 -- 发布时间:2018/8/14 17:48:00 --
|
||||
-- 作者:ZJZK2018 -- 发布时间:2018/8/14 18:00:00 -- .NET Framework 版本:2.0.50727.8762 Foxtable 版本:2018.7.23.1 错误所在事件:窗口,标录信息,AfterLoad 详细错误信息: 未将对象引用设置到对象的实例。 [此贴子已经被作者于2018/8/14 18:05:13编辑过]
|
||||
-- 作者:有点甜 -- 发布时间:2018/8/14 18:28:00 -- 不要设置成自动打开。
照抄代码,afterLoad事件也要写代码。 [此贴子已经被作者于2018/8/14 18:28:37编辑过]
|
||||
-- 作者:ZJZK2018 -- 发布时间:2018/8/15 14:48:00 -- 老师我从论坛中找一了个示例,但不知道下面红色部分 Tb1.Filter = (1 = 2) 这段代码如何调整 Dim s As String = e.Form.Controls("CheckedComboBox筛选树").Text \'Dim tb1 As Table = Tables(e.Form.Name & "_Table1") Dim tb1 As Table = Tables("开标标录台帐_Table1") Dim Colstr() As String Dim qts As String() = {"\'","#",""} Dim trv As WinForm.TreeView = e.Sender Dim flt As String = "" Dim nd As WinForm.TreeNode Dim pd As WinForm.TreeNode Dim notchecked As Integer = 0 Colstr = s.split("|") For i As Integer = 0 To Colstr.Length - 1 If Tb1.Cols.Contains(Colstr(i)) = False Then If trv.Nodes.Count > 0 Then trv.Nodes.Clear() End If \'e.Form.Controls("CheckedComboBox筛选树").Text = "选择筛选列(最好包括拼音)" Return End If Next If e.Node.Name = "显示所有项目" Then If e.Node.Checked = True Then For Each nd In trv.AllNodes If nd.Name <> "显示所有项目" Then nd.Checked = False End If Next Tb1.Filter = "" Else For Each nd In trv.AllNodes nd.Checked = False Next Tb1.Filter = (1 = 2) End If trv.CollapseAll Return Else trv.AllNodes(0).Checked = False End If For Each nd In e.node.allNodes nd.Checked = False Next pd = e.Node.ParentNode Do While pd IsNot Nothing pd.Checked = False pd = pd.ParentNode Loop |
||||
-- 作者:ZJZK2018 -- 发布时间:2018/8/15 14:49:00 -- 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 Tb1.DataTable.DataCols(Colstr(i)).IsString Then If rts(i) <> "空" Then If val > "" Then val = val & " And " val = val & Colstr(i) & " = " & qts(0) & rts(i) & qts(0) Else val = val & Colstr(i) & " = " & qts(0) & rts(i) & qts(0) End If ElseIf rts(i) = "空" Then If val > "" Then val = val & " And " val = val & Colstr(i) & " Is Null" Else val = val & Colstr(i) & " Is Null" End If End If ElseIf Tb1.DataTable.DataCols(Colstr(i)).IsDate Then If rts(i) <> #0001-1-1 0:00:00# Then If val > "" Then val = val & " And " val = val & Colstr(i) & " = " & qts(1) & rts(i) & qts(1) Else val = val & Colstr(i) & " = " & qts(1) & rts(i) & qts(1) End If ElseIf rts(i) = #0001-1-1 0:00:00# Then If val > "" Then val = val & " And " val = val & Colstr(i) & " Is Null" Else val = val & Colstr(i) & " Is Null" End If End If ElseIf Tb1.DataTable.DataCols(Colstr(i)).IsNumeric Then If rts(i) <> 0 Then If val > "" Then val = val & " And " val = val & Colstr(i) & " = " & qts(2) & rts(i) & qts(2) Else val = val & Colstr(i) & " = " & qts(2) & rts(i) & qts(2) End If ElseIf rts(i) = 0 Then If val > "" Then val = val & " And " val = val & Colstr(i) & " Is Null" Else val = val & Colstr(i) & " Is Null" End If End If ElseIf Tb1.DataTable.DataCols(Colstr(i)).IsBoolean Then If rts(i) <> False Then If val > "" Then val = val & " And " val = val & Colstr(i) & " = " & qts(0) & True & qts(0) Else val = val & Colstr(i) & " = " & qts(0) & True & qts(0) End If ElseIf rts(i) = False Then If val > "" Then val = val & " And " val = val & Colstr(i) & " = " & qts(0) & False & qts(0) Else val = val & Colstr(i) & " = " & qts(0) & False & qts(0) End If End If End If Next If flt > "" Then flt = flt & " Or (" & val & ")" Else flt = val End If notchecked + = 1 End If Next Dim dt As DataTable = Vars("dt") Dim nids As String = dt.GetComboListString("系统编号",flt) If flt > "" AndAlso notchecked > 0 Then Tb1.Filter = "系统编号 In (\'" & nids.Replace("|","\',\'") & "\')" Else Tb1.Filter = (1 = 2) End If |
||||
-- 作者:有点甜 -- 发布时间:2018/8/15 15:00:00 -- 不需要改啊
1、你现在这样写有什么问题?
2、当没有勾选的时候,不就是全部都不显示吗? |
||||
-- 作者:ZJZK2018 -- 发布时间:2018/8/15 15:51:00 -- 老师出现二个错误 |
||||
-- 作者:有点甜 -- 发布时间:2018/8/15 16:15:00 --
|