Tal

Tal

  • NA
  • 3
  • 2.2k

Problem in TreeView that has nodes and report that it has'nt

Apr 18 2007 1:59 PM
Adding more then 20 nodes to TREEVIEW all fine here is the simple code:

private void add_Click(object sender, EventArgs e)
{
string st = "node" + cnt.ToString();
TreeNode tn = new TreeNode(st);
tn.Tag = "J" + cnt.ToString();
cnt++;
treeView1.SelectedNode.Nodes.Add(tn);
treeView1.SelectedNode.Expand();
}

BUT if I look at treeView1.HasChildren field its value is == FALSE
there for if I try to get a collection of nodes:

TreeNodeCollection myNodeCollection = treeView1.Nodes;
int myCount = myNodeCollection.Count;
the count is only===> 1 THE ROOT!!!
though I can see the nodes that I have added
and there are more then 20 nodes?????
any clue to whats wrong??

Answers (2)