This is a migrated thread and some comments may be shown as answers.

adding child node - code behind

4 Answers 207 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Pierre asked on 27 Jan 2010, 09:34 AM
Hi@all,

My problem: i have got a treeview, created by the property builder. How can i add a child node in this treeview with my code behind?(c#)  the trigger is a normaly button.

Can someone help me?

thanks
Markus

4 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 27 Jan 2010, 04:32 PM
Hello Markus,

Please refer to the following article which demonstrates how you can add a child node programmatically:
Adding and Removing Nodes.

In short, every RadTreeNode has a Nodes collection, so you can add a child node as it is done in the following code snippet:
this.radTreeView1.Nodes[0].Nodes[2].Nodes.Add(new RadTreeNode("Child node"));

I hope this helps. If you have additional questions, feel free to contact me.

All the best,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Pierre
Top achievements
Rank 1
answered on 30 Jan 2010, 07:43 PM
Hello Nikolay,

thank you very much - this helps me realy. I have one more problem.. perhaps you have got a good solution for the second one:

I build my treeview with the property builder and some nodes created by code. so - it is posibile to "refresh" one item? I will change  some images from a node (created by code (dynamicly) and builder)

? find - delete and create ? or can a change the image on runtime by code?

thanks
Markus
0
Nikolay
Telerik team
answered on 01 Feb 2010, 03:59 PM
Hello Markus,

Thank you for the question.

In order to set an image to a RadTreeNode at runtime, just assign an image object to the RadTreeNode.Image property. I am demonstrating this behavior in the attached sample project. As you will notice, I am using the FindByTextCommand which allows me to easily find a node and set its properties.

I am not sure that I understand the requirement from your last sentence. Could you please provide me with additional details about it?

Kind regards,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Stefan
Telerik team
answered on 18 Mar 2011, 08:51 AM
Hi Markus,

Please note that in Q1 2011 we have introduced a major upgrade of RadTreeView control, which is now virtualized and fully customizable. Feel free to download the latest release and try it out.
For more information about this release, please refer to this blog post.

Regards,
Stefan
the Telerik team
Tags
Treeview
Asked by
Pierre
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Pierre
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or