以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]自己做个如系统自带的加载树,请老师完善下代码 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=149790) |
-- 作者:huangfanzi -- 发布时间:2020/5/12 13:29:00 -- [求助]自己做个如系统自带的加载树,请老师完善下代码 请老师帮忙改下代码,要求当勾选“加载所有行”后,就加载所有数据,同时其他所有选项全部清空,当勾选其它任一个选项后,“加载所有行”就取消勾选 谢谢老师! Dim cb As WinForm.ComboBox = e.Form.Controls("ComboBox_设置名选择") Dim trv As WinForm.TreeView = e.Sender Dim s As String Dim s1 As String Dim n As Integer Dim dr As DataRow If cb.Value = Nothing Then Return Else dr = _dt用户配置参数表.SQLFind("用户名 = \'" & _UserName & "\' And 表名 = \'" & MainTable.Name & "\' And 类型 = \'加载树设置\' And 生效 = 1 And 设置名 = \'" & cb.Value & "\'" ) If dr IsNot Nothing Then s = dr("值") ‘加载树字段 n = dr("值1") ’加载记录数 s1 = dr("值2") ‘排序字段 Else MessageBox.Show("错误,在【" & MainTable.Name & "】中,此设置的加载树已经被删除,请重新选择设置名!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If End If Dim tbl As Table = MainTable \'Tables(e.Form.Name & "_Table_对外采购") Dim nms As String() = s.Split(",") \'指定生成目录树的各列 Dim qts As String() \'将各列的值括起来的符号数组,会从fh集合中引入 Dim fh As New List(Of String) \'将各列的值括起来的符号集合,字符与日期用单引号,数值不用符号 Dim jh As New List(of String) jh.AddRange(nms) \'将数组中的元素全部加入到集合中 For Each nm As String In jh If tbl.Cols(nm).IsString OrElse tbl.Cols(nm).IsDate Then fh.Add("\'") ElseIf tbl.Cols(nm).IsNumeric Then fh.Add("") Else If tbl.Cols(nm).IsBoolean Then fh.Add("") End If Next qts = fh.ToArray() \'集合转数组 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 If rts(i).tolower = "true" Then val = val & nms(i) & " = 1" ElseIf rts(i).tolower = "false" Then val = val & nms(i) & " = 0" Else val = val & nms(i) & " = " & qts(i) & rts(i) & qts(i) End If Next If flt > "" Then flt = flt & " Or (" & val & ")" Else flt = val End If End If Next If flt = Nothing Then flt = "[_Identify] Is Null" End If Dim dt As DataTable = MainTable.DataTable With dt .LoadFilter = flt \'设置加载条件 .LoadPage = 0 \'加载第一页 .LoadTop = n \'每页加载的行数 .LoadOver = "_Identify" \'加载分页字段 .Load() e.Form.Controls("TextBox_页码").Value = 1 & "/" & .TotalPages End With MainTable.Sort = s1 MainTable.AutoSizeCols() [此贴子已经被作者于2020/5/12 13:29:29编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/5/12 14:09:00 -- AfterCheckNode事件 If e.node.text = "加载所有行" If e.Node.Checked For Each nd As WinForm.TreeNode In e.Sender.allNodes \'清除节点的选中标记 nd.Checked = False Next e.node.Checked = True End If End If |