title: VB.net Populate TreeView with DataSet using Parent-Child Relations
body: <p>I'm working on a program that allows me to edit XML data in a DataGridView.  I have most everything working but I don't like my current TreeView Structure.</p>
  
  <p>I load the XML data into a DataSet and edit it there, so that is what I'd prefer to base my TreeView on.  I've tried a few things such as..</p>
  
  <pre><code>Private Sub updateTree()
      'Clear All Previous TreeView Nodes
      TreeView1.Nodes.Clear()
      'Loop Through XML Nodes and Add them to the Tree
      For Each table As DataTable In ds.Tables
          Dim node As New TreeNode(table.TableName)
          If table.ChildRelations.Count = 0 Then
              node.Text = table.TableName
              node.Tag = table.TableName
              TreeView1.Nodes.Add(node)
          Else
              node.Tag = table.TableName
              node.Text = table.TableName &amp; " - No Child Objects"
              TreeView1.Nodes.Add(node)
          End If
      Next
  End Sub
  </code></pre>
  
  <p>What I'd really like to have is a tree view that shows the Parent Child objects nested.  I'm not sure exactly how to accomplish that in this case...  Any ideas??  I found this, article, but don't have many more leads... </p>
  
  <p><a href="https://stackoverflow.com/questions/6662223/adding-nested-treeview-nodes-in-vb-net">Adding Nested Treeview Nodes in VB.NET?</a> </p>
  
  <p>Thanks.</p>