adding child node - code behind

5 posts, 1 answers
  1. Pierre
    Pierre avatar
    15 posts
    Member since:
    Jun 2008

    Posted 27 Jan 2010 Link to this post

    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

  2. Answer
    Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 27 Jan 2010 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Pierre
    Pierre avatar
    15 posts
    Member since:
    Jun 2008

    Posted 30 Jan 2010 Link to this post

    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
  5. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 01 Feb 2010 Link to this post

    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.
  6. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 18 Mar 2011 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready