Automatically add missing parent nodes

2 posts, 0 answers
  1. Chris Ward
    Chris Ward avatar
    54 posts
    Member since:
    Jan 2010

    Posted 30 Apr 2014 Link to this post

    I was expecting that calling AddNodeByPath would automatically create the necessary parent nodes similar to how Directory.Create() works.


    However, it just seems to add them all to the closest node it could find (if there are no nodes, then a bunch of "Report.txt" will be in the root node).

    I have come up with the following to solve this issue, but I'm wondering if there's an easier way?

    private RadTreeNodeCollection AddNode(string path)
        if (path == String.Empty)
            return treeView.Nodes;
        string node = Path.GetFileName(path);
        RadTreeNodeCollection parent = AddNode(Path.GetDirectoryName(path));
        if (parent.Contains(node))
            return parent[node].Nodes;
            return parent.Add(node).Nodes;

    Is this a bug, or is it documented somewhere that AddNodeByPath() doesn't create the necessary parent nodes?
  2. George
    George avatar
    500 posts

    Posted 01 May 2014 Link to this post

    Hello Chris,

    Thank you for contacting us.

    We consider that the AddNodeByPath method should create parent nodes where they do not exist. That is why I have logged it in our Feedback Portal. You can find it on the following url: UI for Winforms Feedback Portal - FIX. RadTreeView - AddNodeByPath does not create parent nodes if they do not exist. Feel free to add your votes/comments or subscribe for changes.

    I have updated Telerik Points to your account as a token of gratitude for your report.

    Let me know if you have further questions.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Back to Top