How do you insert a child node in a TreeView Control in WPF C#?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: How do you insert a child node in a TreeView Control in WPF C#?

  1. #1
    Join Date
    Dec 2005
    Posts
    180

    How do you insert a child node in a TreeView Control in WPF C#?

    How do you insert a child node in a TreeView Control in WPF C#?

    I have a TreeView control that I have created in XAML in a WPF program using C#.

    After adding a couple nodes at the root level, I have written code that loops through the tree structure like so:

    ItemCollection items = treeView1.Items;
    foreach (TreeViewItem n in items)
    {
    ...
    }

    Once I find the place in this loop where I want to include a child node, how do I go about inserting a child?

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: How do you insert a child node in a TreeView Control in WPF C#?

    Each node has its own collection of nodes, just add it to that. Also realize that if you want to walk the entire tree at a later time you will need a recursive solution.
    If you liked my post go ahead and give me an upvote so that my epee.... ahem, reputation will grow.

    Yes; I have a blog too - http://the-angry-gorilla.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center