以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]目录树定位到增加的节点上  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=69188)

--  作者:blsu33
--  发布时间:2015/6/1 10:59:00
--  [求助]目录树定位到增加的节点上
老师,
下列的代码如何使节点定位到增加目录树节点上。
Dim tr As WinForm.TreeView
Dim nd As WinForm.TreeNode=tr.SelectedNode
tr = e.Form.Controls("TreeView1")
tr.ExpandAll
If tr.Nodes.Count=0 Then
    MessageBox.Show("请先增加根节点!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
    \'nd = tr.SelectedNode   
    Dim nm As String ="点" & Vars("numbh")
    If nd IsNot Nothing Then
        Select nd.Level
            Case 0
                If nd.Nodes.Contains(nm) = False
                    nd.Nodes.Add(nm)
                    Dim dr As DataRow = DataTables("角色管理").AddNew
                    dr("角色")=nd.Text  & "\\" & "点" & Vars("numbh")
                    Vars("numbh")=Vars("numbh")+1
                    tr.Select
                    tr.BeginEdit
                    tr.ExpandAll
                End If
            Case 1
                If nd.Nodes.Contains(nm) = False
                    nd.Nodes.Add(nm)
                    Dim dr As DataRow = DataTables("角色管理").AddNew
                    dr("角色")=nd.ParentNode.Text & "\\"  & nd.Text & "\\" & "点" & Vars("numbh")
                    Vars("numbh")=Vars("numbh")+1
                    tr.SelectedNode = nd
                    tr.Select
                    tr.BeginEdit
                    tr.ExpandAll
                End If
            Case 2
                If nd.Nodes.Contains(nm) = False
                    nd.Nodes.Add(nm)
                    Dim dr As DataRow = DataTables("角色管理").AddNew
                    dr("角色")=nd.ParentNode.ParentNode.Text & "\\"  & nd.ParentNode.Text & "\\"  & nd.Text & "\\" & "点" & Vars("numbh")
                    Vars("numbh")=Vars("numbh")+1
                    tr.SelectedNode = nd
                    tr.Select
                    tr.BeginEdit
                    tr.ExpandAll
                End If
            Case Else
                MessageBox.Show("最多允许四层节点!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End Select
    End If
End If

--  作者:Bin
--  发布时间:2015/6/1 11:02:00
--  
tr.SelectedNode    = tr.nodes.add("新增节点")
--  作者:大红袍
--  发布时间:2015/6/1 11:02:00
--  
Dim nnd = nd.Nodes.Add(nm)
Dim dr As DataRow = DataTables("角色管理").AddNew
dr("角色")=nd.ParentNode.ParentNode.Text & "\\"  & nd.ParentNode.Text & "\\"  & nd.Text & "\\" & "点" & Vars("numbh")
Vars("numbh")=Vars("numbh")+1
\'tr.SelectedNode = nd
\'tr.Select
\'tr.BeginEdit
\'tr.ExpandAll
tr.SelectedNode = nnd

--  作者:blsu33
--  发布时间:2015/6/1 13:02:00
--  
谢谢二位老师,已解决。