How to add nodes dynamically to a already existing treeview?
if an example as,
-Root
-child1
above one is already existing treeview. but i want to add one more node(child2) to the Root, output is like..
-Root
-child1
-child2
Try this:
TreeNode rootNode = TreeView.Nodes.Cast<TreeNode>().ToList().Find(n => n.Text.Equals("Root"));
if (rootNode != null)
{
rootNode.Nodes.Add("child2");
}
try:
treeView1.Nodes.Add(new TreeNode())
Details are found here: http://msdn.microsoft.com/de-de/library/system.windows.forms.treeview.nodes.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With