以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 动态生成目录树问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=68497) |
-- 作者:Bin -- 发布时间:2015/5/19 11:34:00 -- 没看懂需求 |
-- 作者:don -- 发布时间:2015/5/19 13:50:00 -- Dim s1,s2,s3,sql As String For Each s1 In "类型,生产线,品种".split(",") If Forms("窗口1").Controls(s1).checked = True Then s2 + = "," & s1 s3 + = "|" & s1 End If Next sql ="SELECT DISTINCT Year(日期) As 年, Month(日期) As 月 " & s2 & " F rom {表A}" Dim cmd As New SQLCommand \'cmd.C Dim dt As DataTable cmd.CommandText = sql dt = cmd.ExecuteReader() Dim trv As WinForm.TreeView = Forms("窗口1").Controls("TreeView1") trv.BuildTree(dt, "年|月" & s3) [此贴子已经被作者于2015/5/19 13:52:39编辑过]
|
-- 作者:don -- 发布时间:2015/5/19 15:13:00 -- 以下是引用liuruihua在2015/5/19 14:39:00的发言: 谢谢don,您的代码基本能实现我想要的结果,如果能实现对各复选框的勾选顺序进行分层级就更好,即先勾选的排放在前一级。 也可以:設一全局字符變量: Vars("LSP") 1.CheckedChanged If "类型,生产线,品种".Contains(e.Sender.name) Then If e.Sender.checked Then Vars("LSP")+ = "," & e.Sender.name Else Vars("LSP") = Vars("LSP").Replace("," & e.Sender.name,"") End If End If 2. \'[窗口1] 的AfterLoad Vars("LSP") = Nothing 3. Dim s1,sql As String if Vars("LSP") > "" then s1 = Vars("LSP").Replace(",","|") End if sql ="SELECT DISTINCT Year(日期) As 年, Month(日期) As 月 " & Vars("LSP") & " F rom {表A}" Dim cmd As New SQLCommand \'cmd.C Dim dt As DataTable cmd.CommandText = sql dt = cmd.ExecuteReader() Dim trv As WinForm.TreeView = Forms("窗口1").Controls("TreeView1") trv.BuildTree(dt, "年|月" & s1) [此贴子已经被作者于2015/5/19 15:17:02编辑过]
|
-- 作者:大红袍 -- 发布时间:2015/5/19 19:13:00 -- 你可以参考这个
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=32484&skin=0
|
-- 作者:大红袍 -- 发布时间:2015/5/19 19:16:00 -- http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=44369&skin=0
|
-- 作者:don -- 发布时间:2015/5/19 23:50:00 -- Dim Lst As New List(of String) Dim s2,sql As String Lst.AddRange(e.Node.FullPath.split("\\")) sql = "select * F" & "rom {表A} where Year(日期) = " & Lst(0) If Lst.count > 1 Then sql = sql & " and Month(日期) = " & Lst(1) If Lst.Count > 2 Then For n1 As Integer = 2 To Lst.count -1 s2 = s2 & " and " & Vars("LSP").split(",")(n1-1) & " = \'" & Lst(n1) & "\'" Next sql+= s2 End If e.Form.Controls("Table1").Table.FILL(sql,"",1)
|