I need to remove particular child nodes from their parent in treeview control.
For example:
Before Login
home
-register
-开发者_如何学Clogin
-pdf
After login
home
-pdf
What is the best way to accomplish this?
should be like...
//This will remove login
TreeNode tn = TreeView1.FindNode("home/login"); // find particular node
TreeView1.Nodes[0].ChildNodes.Remove(tn); // then remove from TreeView
//This will remove register
tn = TreeView1.FindNode("home/register"); // find particular node
TreeView1.Nodes[0].ChildNodes.Remove(tn); // then remove from TreeView
Adding child node in parent node programmatically:
TreeNode tn = new TreeNode("login");
tn.NavigateUrl = "/home/login";
TreeView1.Nodes[0].ChildNodes.Add(tn);
精彩评论