C# .NET generating trees - child nodes?

  • Thread starter Thread starter Liz
  • Start date Start date
L

Liz

C# .NET creating a tree programmatically

treeView1.BeginUpdate();
treeView1.Nodes.Clear();
treeView1.Nodes.Add(new TreeNode("Client Details"));
tvSelect.Nodes.Add(new TreeNode("Referrals"));
tvSelect.EndUpdate();

Can anyone tell me how I add child nodes to the above
tree?

Liz
 
Liz,
Your
treeView1.Nodes.Add(new TreeNode("Client Details"));
will return a reference to a TreeNode class which you can then add more
subnodes to.

HTH
Kieran
 
Thanks for the pointer Kieran - Liz
-----Original Message-----
Liz,
Your
treeView1.Nodes.Add(new TreeNode("Client Details"));
will return a reference to a TreeNode class which you can then add more
subnodes to.

HTH
Kieran




.
 
Sorry to be so thick Kieran, but could you kindly show me
an example?? I seem to be going round in circles trying
to get this to work - Liz
 
Liz,

Sure thing.

treeView1.BeginUpdate();
treeView1.Nodes.Clear();
TreeNode node1 = new TreeNode("Client Details");
treeView1.Nodes.Add(node1);
node1.Nodes.Add(new TreeNode("Address1"));
treeView1.EndUpdate();

Sorry I actually probably confused you there slightly! My understanding that
Nodes.Add returned a TreeNode was incorrect!

HTH
Kieran
 
Kieran,

Thanks. I was getting myself tied up in nesting. It's
really much the same as the VB version I had, once you
get tuned into the C# syntax. Thank you for your help.
Liz
 
Back
Top