开发者

child node removing from treeview in c#

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);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜