title: Populate a TreeView from an object
body: <p>I am having a problem with a <code>treeview</code> in my WinForm app.  I created a TreeViewItem class that holds the data.  There are only 5 fields: <strong>CaseNoteID, ContactDate, ParentNoteID, InsertUser, ContactDetails.</strong></p>
  
  <pre><code>public class TreeItem
  {
      public Guid CaseNoteID;
      public Guid? ParentNoteID;
      public string ContactDate;
      public string InsertUser;
      public string ContactDetails;
  
      public TreeItem(Guid caseNoteID, Guid? parentNoteID, string contactDate, string contactDetails, string insertUser)
      {
          CaseNoteID = caseNoteID;
          ParentNoteID = parentNoteID;
          ContactDate = contactDate;
          ContactDetails = contactDetails;
          InsertUser = insertUser;
      }
  }
  </code></pre>
  
  <p>The plan was to show relationships of the notes by showing a note under it's parent as determined by the <strong>ParentNoteID</strong> field.  Pretty simplistic really.  Unfortunately, all my attempts so far have put a "child" note, one with a ParentNoteID, in both positions.  The first level <strong>AND</strong> under it's appropriate Parent.</p>
  
  <p>When I step through my code my data is coming back accurately.</p>
  
  <pre><code> List&lt;TreeItem&gt; items = BLLMatrix.GetTreeViewData(HUD.PersonId);
          PopulateTree(tvwCaseNotes,items);
  </code></pre>
  
  <p>I just don't know how to take that and populate my <code>TreeView</code> accurately with it.  This is what I started but now I am stuck. </p>
  
  <pre><code>  public static void PopulateTree(TreeView tree, ICollection&lt;TreeItem&gt; items)
  </code></pre>
  
  <p>I just don't seem able to wrap my head around it.  Do I need to split my data call up and first return all entrys with <code>ParentNoteID = null</code> and then go get the rest and <em>somehow</em> join the two?</p>
  
  <p>@Hogan: I apologize for the drastic change in the question.  It was evident from your response that I hadn't approached this from a good angle in the first place.  In the second place, the original method still did not work.</p>