wow

wow

  • NA
  • 8
  • 0

Add to treeView not working

Oct 16 2009 7:40 PM
Hi there,

I can't get the line that was read from the file added to my treeview.  So here is what my code is doing.  It reads through a file line by line and adds a line at a time into my treeview.  My code runs through with no error. 

+ tree
 |___ node1
        |___ line   < line should be inserted here, but not working >

Any help or pointers is greatly appreciated.

 StreamReader sr = new StreamReader(somefile);

while(line = sr.ReadLine() != null)
{
TreeNode tn = new TreeNode();
tn.text = line;

MessageBox.Show(line); // Test to see if it reaches here and what the node before adding.

treeView1.Nodes[0].Nodes[0].Nodes.Add(tn);
}


Answers (7)