使用Child_ID,Child_Name,Parent_ID,Parent_Name填充Treeview

时间:2015-10-08 09:32:49

标签: vb.net treeview

美好的一天,

我正在将一个表从SQL Server导出到Access数据库中,我需要从中构建一个树视图并为每个节点分配值。我是使用VB .net。

进行树视图处理的新手

表结构是这样的。

** Child_ID ChildName Parent_ID ParentName **

对于每个子对象,都有一个父ID。 任何专家都可以建议使用上面的列填充treeview的方法吗?在此过程中,我想将ChildName / ParentName指定为TreeNode文本(displyName),将Child_ID / Parent_ID指定为我想在另一个应用程序中使用的treenode标记。

提前致谢。

  RootName = "AppRootName" 

                            Dim root = New TreeNode(RootName)
                            MyTreeView.Nodes.Add(root)
                            MyTreeView.TopNode = root

                            For Each dbRow As DataRow In DTHier.Rows
                                ChildName = dbRow.Item(0).ToString()
                                ChildID = dbRow.Item(1).ToString().ToUpper  
                                ParentID = dbRow.Item(2).ToString().ToUpper
                                ParentName = dbRow.Item(3).ToString() 

                                Dim ParentNode = New TreeNode() With { _
                                   .Name = ParentName.ToString(), _
                                    .Text = ParentName, _
                                    .Tag = ParentID _
                               }

                                Dim ChildNode = New TreeNode() With { _
                                  .Name = ChildName.ToString(), _
                                   .Text = ChildName, _
                                   .Tag = ChildID _
                              }


                                MyTreeView.Nodes(0).Nodes.Add(ParentNode)

                                Dim NodeFound As Integer = MyTreeView.Nodes(0).Nodes.Find(ChildNode.Tag, True).Length
                                If NodeFound > 0 Then
                                    ParentNode.Nodes.Add(ChildNode)
                                End If

1 个答案:

答案 0 :(得分:1)

您可以尝试一下:

cmd = 'ls /home/dir'
self.ssh_stdin, self.ssh_stdout, self.ssh_stderr = self.ssh.exec_command(cmd)
print self.ssh_stdout.read()
cmd2 = 'cat /home/dir/test.log'
self.ssh_stdin2, self.ssh_stdout2, self.ssh_stderr2 = self.ssh.exec_command(cmd2)
print self.ssh_stdout2.read()
相关问题