以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 节点对应列的赋值 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=67640) |
|
-- 作者:blsu33 -- 发布时间:2015/4/28 11:06:00 -- 节点对应列的赋值 老师, 目录树一共四级 If Vars("Tree") = True Then Dim tr1 As WinForm.TreeView = e.Form.Controls("TreeView1") Dim tr2 As WinForm.TreeView = e.Form.Controls("TreeView2") Dim nd1 As WinForm.TreeNode = tr1.SelectedNode Dim nd2 As WinForm.TreeNode = tr2.SelectedNode Dim dr As DataRow Select Case nd2.Level Case 0 dr = DataTables("权限管理").Find("功能主模块 = \'" & nd2.Text & "\' And 权限 Is Null") Case 1 dr = DataTables("权限管理").Find("功能主模块 = \'" & nd2.ParentNode.Name & "\' And 一级模块 = \'" & nd2.Text & "\' And 权限 Is Null") Case 2 dr = DataTables("权限管理").Find("功能主模块 = \'" & nd2.ParentNode.ParentNode.Name & "\' And 一级模块 = \'" & nd2.ParentNode.Name & "\' And 二级模块 = \'" & nd2.Text & "\' And 权限 Is Null") Case 3 dr = DataTables("权限管理").Find("功能主模块 = \'" & nd2.ParentNode.ParentNode.ParentNode.Name & "\' And 一级模块 = \'" & nd2.ParentNode.ParentNode.Name & "\' And 二级模块 = \'" & nd2.ParentNode.Name & "\'And 权限 = \'" & nd2.Text & "\'") End Select If nd2.Checked = True Then dr("角色") = nd1.Text + "/" + dr("角色") Else dr("角色") = dr("角色").Replace(nd1.Text,"") End If dr("角色") = dr("角色").Trim("/") For Each nd As WinForm.TreeNode In e.Node.AllNodes nd.Checked = e.Node.Checked 这里怎么写才能达到,选定的节点对应的标的角色列全部赋值,举例 选定是 一级节点全部节点选定了,全部节点对应4行,这4行的 角色列全部赋值 Next End If
[此贴子已经被作者于2015/4/28 11:06:56编辑过]
|
|
-- 作者:Bin -- 发布时间:2015/4/28 11:08:00 -- 黄色部分什么都不用写. 只要你前面写对就可以了 只要你为对应的节点Checked赋值了.就会除非NodekChecked事件 那么就会执行一遍你上面的代码.
|
|
-- 作者:blsu33 -- 发布时间:2015/4/28 11:12:00 -- 老师 , 是这个意思吗, For Each nd As WinForm.TreeNode In e.Node.AllNodes nd.Checked = e.Node.Checked 只要条件满足了, 重新执行 If Vars("Tree") = True Then Dim tr1 As WinForm.TreeView = e.Form.Controls("TreeView1") Dim tr2 As WinForm.TreeView = e.Form.Controls("TreeView2") Dim nd1 As WinForm.TreeNode = tr1.SelectedNode Dim nd2 As WinForm.TreeNode = tr2.SelectedNode Dim dr As DataRow Select Case nd2.Level Case 0 dr = DataTables("权限管理").Find("功能主模块 = \'" & nd2.Text & "\' And 权限 Is Null") Case 1 dr = DataTables("权限管理").Find("功能主模块 = \'" & nd2.ParentNode.Name & "\' And 一级模块 = \'" & nd2.Text & "\' And 权限 Is Null") Case 2 dr = DataTables("权限管理").Find("功能主模块 = \'" & nd2.ParentNode.ParentNode.Name & "\' And 一级模块 = \'" & nd2.ParentNode.Name & "\' And 二级模块 = \'" & nd2.Text & "\' And 权限 Is Null") Case 3 dr = DataTables("权限管理").Find("功能主模块 = \'" & nd2.ParentNode.ParentNode.ParentNode.Name & "\' And 一级模块 = \'" & nd2.ParentNode.ParentNode.Name & "\' And 二级模块 = \'" & nd2.ParentNode.Name & "\'And 权限 = \'" & nd2.Text & "\'") End Select If nd2.Checked = True Then dr("角色") = nd1.Text + "/" + dr("角色") Else dr("角色") = dr("角色").Replace(nd1.Text,"") End If dr("角色") = dr("角色").Trim("/") |
|
-- 作者:Bin -- 发布时间:2015/4/28 11:18:00 -- 是的. |
|
-- 作者:blsu33 -- 发布时间:2015/4/28 11:43:00 -- 明白了,老师代码改为下面的 If Vars("Tree") = True Then Dim tr1 As WinForm.TreeView = e.Form.Controls("TreeView1") Dim tr2 As WinForm.TreeView = e.Form.Controls("TreeView2") Dim nd1 As WinForm.TreeNode = tr1.SelectedNode Dim nd2 As WinForm.TreeNode = tr2.SelectedNode Dim Vals() As String = ND2.FullPath.Split("\\") Dim Filter As String = "功能主模块 = \'" & Vals(0) & "\' AND 一级模块 = \'" & Vals(1) & "\' AND 二级模块 = \'" & Vals(2) & "\' AND 权限 = \'" & Vals(3) & "\'" Dim dr As DataRow = DataTables("权限管理").Find(Filter) If DR IsNot Nothing Then If nd2.Checked = True Then dr("角色") = nd1.Text + "/" + dr("角色") Else dr("角色") = dr("角色").Replace(nd1.Text,"") End If dr("角色") = dr("角色").Trim("/") End If For Each nd As WinForm.TreeNode In e.Node.AllNodes nd.Checked = e.Node.Checked Next End If |
|
-- 作者:blsu33 -- 发布时间:2015/4/28 11:43:00 -- 但是 筛选不起作用,显示未应用到对象 |
|
-- 作者:Bin -- 发布时间:2015/4/28 11:44:00 -- if dr isnot nothing then If nd2.Checked = True Then dr("角色") = nd1.Text + "/" + dr("角色") Else dr("角色") = dr("角色").Replace(nd1.Text,"") End If dr("角色") = dr("角色").Trim("/") end if
|
|
-- 作者:blsu33 -- 发布时间:2015/4/28 11:49:00 -- 索引超出了数组界限。 是不是我这块写的不对呢 Dim Filter As String = "功能主模块 = \'" & Vals(0) & "\' AND 一级模块 = \'" & Vals(1) & "\' AND 二级模块 = \'" & Vals(2) & "\' AND 权限 = \'" & Vals(3) & "\'"
|
|
-- 作者:blsu33 -- 发布时间:2015/4/28 11:50:00 -- 末级可以赋值 |
|
-- 作者:Bin -- 发布时间:2015/4/28 11:51:00 -- 你用到3级要判断一下 判断Leve=3 或者 if Vals.length=4 then
|