以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]TreeView代码救助 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=64926) |
-- 作者:huangfanzi -- 发布时间:2015/3/5 10:48:00 -- [求助]TreeView代码救助 以下代码执行后,在控件“CheckBox_仅显库存”上打上勾,再点TreeView上任何节点,能正常筛选,这时,再把TreeView上的勾去掉,就弹出错误了,内容是:语法错误:“And”运算符前缺少操作数。,我把代码改了好几次,也没解决,请老师看看错在哪了,谢谢! 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 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 If e.node.Text = "加载所有数据" Then For Each nd In trv.AllNodes If nd.Name <> e.Node.Name Then nd.Checked = False Next flt = "1=1" Else For Each nd In trv.AllNodes If nd.Checked Then trv.Nodes(0).Checked = False \'最上面"加载所有数据" 选择框去掉 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 If e.Form.Controls("CheckBox_仅显库存").checked=True Then Tables("工序合并表查询独立窗口_Table_工序合并表").Filter = flt & " and [库存标记] = True" Else Tables("工序合并表查询独立窗口_Table_工序合并表").Filter = flt End If |
-- 作者:有点甜 -- 发布时间:2015/3/5 10:51:00 -- If e.Form.Controls("CheckBox_仅显库存").checked=True Then Tables("工序合并表查询独立窗口_Table_工序合并表").Filter = iif(flt="","1=1",flt) & " And [库存标记] = True" Else Tables("工序合并表查询独立窗口_Table_工序合并表").Filter = flt End If |
-- 作者:Bin -- 发布时间:2015/3/5 10:52:00 -- If e.Form.Controls("CheckBox_仅显库存").checked=True andalso flt <> "" Then |
-- 作者:lsy -- 发布时间:2015/3/5 10: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 If e.node.Text = "加载所有数据" Then For Each nd In trv.AllNodes If nd.Name <> e.Node.Name Then nd.Checked = False Next flt = "1=1" Else For Each nd In trv.AllNodes If nd.Checked Then trv.Nodes(0).Checked = False \'最上面"加载所有数据" 选择框去掉 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 If flt = "" Then flt = "1 = 1" End If If e.Form.Controls("CheckBox_仅显库存").checked=True Then Tables("工序合并表查询独立窗口_Table_工序合并表").Filter = flt & " and [库存标记] = True" Else Tables("工序合并表查询独立窗口_Table_工序合并表").Filter = flt End If
|
-- 作者:huangfanzi -- 发布时间:2015/3/5 12:21:00 -- 天,三位大神帮我解答,而且用了三种方式,我好好学习一下。 再请教一个关于上面筛选树的问题。 上面的代码中有个瑕疵,筛选树有三级{"牌号","母卷号","卷号"},当我选择2级或3级时,上一级的勾不会自动打上,例如勾2级时,对应的1级应该打上勾,如果勾了3级,哪么对应的2级与1级也应该勾上,老师能帮我改下代码吗?
|
-- 作者:有点甜 -- 发布时间:2015/3/5 14:12:00 -- 回复5楼,你这样不合理啊,勾选以后,下次,查询的时候,就根据勾选的结果查询了啊,肯定不正确啊。 |