How do you add a GrandChild node?

9 posts, 0 answers
  1. Gary Robson
    Gary Robson avatar
    14 posts
    Member since:
    Mar 2009

    Posted 20 Aug 2009 Link to this post

    I'm sure this is simple but it's got me foxed.
    I want to add a child node to a child node.

    I store the location I want to place the new node, in this case parent node 0 and child node 0

                If r("DocNode1") = 0 And r("DocNode2") = 0 Then

                    tvDocs.Nodes(0).Nodes.Add((r("DocTitle"))) '<<< How do I add the GrandChild node ?

                End If

    Thanks.
  2. Gary Robson
    Gary Robson avatar
    14 posts
    Member since:
    Mar 2009

    Posted 20 Aug 2009 Link to this post

    Isn't it just typical, after you search for hours for an answer, then go to the trouble to ask for help, five minutes later your crack it.

    tvDocs.Nodes(0).Nodes(0).Nodes.Add((r("DocTitle")))
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 20 Aug 2009 Link to this post

    Hello Gary Robson,

    Thank you for sharing with the community your solution and do not hesitate to write in our forums if you encounter something else.

    Greetings,
    Victor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. H Vi
    H Vi avatar
    3 posts
    Member since:
    Feb 2010

    Posted 09 Mar 2010 Link to this post

    Good afternoon,

    I am currently facing the exact same problem as Gary Robson, however, I am under these conditions/restraints;
    >>I do not know how many 'grandparent' does the node has. Meaning... it could be something like;

    -Node1
    |--Node2
    |----Node3
    |--Node4
    |----Node5
    |----Node6
    |------Node7

    In this case, for example, if I am at Node7, my parent is Node6, grandparent is Node4 and great-grandparent is Node1.
    Assuming I do not know about grandparent Node4 and great-grandparent Node1...
    Am I still able to add? My 'expected' result is;

    -Node1
    |--Node2
    |----Node3
    |--Node4
    |----Node5
    |----Node6
    |------Node7
    |--------[Node8]
    Node 8, to be added.

    I have tried using 'Insert', but it would put Node8 at the same level as its parent, Node7, giving me this;
    -Node1
    |--Node2
    |----Node3
    |--Node4
    |----Node5
    |----Node6
    |------Node7
    |------[Node8]
    Ranking Node8 and Node7 to be sibling-level, and not parent-child.

    I appreciate all help given.
    Thanks and yours sincerely,
    H. Vi
  6. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 09 Mar 2010 Link to this post

    Hello H Vi,

    Thank you for contacting us. You simply need to add Node8 to the Nodes collection of Node7.

    Best wishes,
    Victor
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. H Vi
    H Vi avatar
    3 posts
    Member since:
    Feb 2010

    Posted 09 Mar 2010 Link to this post

    Good evening Victor,
    Thank you for your prompt reply!

    I would like to add that umm, Node8 -and- Node7 are all created during runtime.

    I am unable to find a 'collection' to add. I am sorry if this sounds confusing. Currently, I 'insert' nodes like this;
    radTreeView1.Nodes.Insert (parIDInTree + 1, newNode);
    *parIDInTree is the Parent Node's ID in the Tree Form. This of course, doesn't work, since the added node becomes a 'sibling' node.

    I also tried;
    radTreeView1.Nodes[parentName].Nodes.Add(newNode);
    *Where... in a self explanatory manner, I try to add the node under its parent's name. However, as there are 'grandparents', this is not feasible either.

    I have no idea where to 'plug in' the Collections keyword.

    Sorry for all the trouble, and a sincere thanks for the prompt reply~
    Yours sincerely,
    H. Vi

  8. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 10 Mar 2010 Link to this post

    Hello H Vi,

    If you know the name of the parent node to which you to add the child node, you can find it by using RadTreeView command mechanism and FindByTextCommand in particular. You can first use the command to get a reference to the parent and then add the child node to the parent Nodes collection. Here is an example:

    FindByTextCommand cmd = new FindByTextCommand();
    object parent = RadTreeView.ExecuteScalarCommand(yourTreeView.Nodes, -1, cmd, "Node8");
    if(parent != null)
    {
        (parent as RadTreeNode).Nodes.Add(childNode);
    }

    Write again if you need further assistance.

    All the best,
    Victor
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  9. H Vi
    H Vi avatar
    3 posts
    Member since:
    Feb 2010

    Posted 10 Mar 2010 Link to this post

    Good morning Victor,

    Thanks sincerely for the code snippet! This is exactly what I am looking for!

    I too, have learnt something new. Thank you so much for your help and advice.

    Yours sincerely,
    H. Vi
  10. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 11 Mar 2010 Link to this post

    Hello H Vi,

    Thank you, I am glad to be of help.

    Sincerely yours,
    Victor
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
UI for WinForms is Visual Studio 2017 Ready