Welcome Guest Search | Active Topics | Sign In | Register

How to insert a TreeNode in TreeView? Options
Jack.Wu
Posted: Thursday, June 17, 2010 11:52:46 PM
Rank: Advanced Member
Groups: Member

Joined: 5/22/2009
Posts: 33
Hello Sir,

The following is my code to insert a node but it can not insert after a sub node, please help to let me know the correct way. Thank you.

// Insert a new node to TreeView
EO.Web.TreeNode currentNode = areaCodeTreeView.SelectedNode;
index = currentNode.Index;
//index = areaCodeTreeView.Nodes.IndexOf(currentNode);

EO.Web.TreeNode newNode = new EO.Web.TreeNode("New added code");
newNode.AllowEdit = EO.Web.NullableBool.True;

this.areaCodeTreeView.Nodes.Insert(index, newNode);

My problem is that if I want to insert a node under "100", using the code above, it will insert a node between "100" and "200". How can I insert a node under "100"? Thank you for your help.

Root
+--- 100
+--- 200
eo_support
Posted: Friday, June 18, 2010 8:32:22 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You can use something like this:

areaCodeTreeView.Nodes[0].ChildNodes.Add(newNode);

Please take a look of the API reference section for all available properties/methods.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.