开发者

child node removing from treeview in c#

开发者 https://www.devze.com 2023-02-15 16:41 出处:网络
I need to remove particular child nodes from their parent in treeview control. For example: Before Login

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

精彩评论

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