Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4119580
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:06:31+00:00 2026-05-20T23:06:31+00:00

I Have a treeView Already populated (in vb.net) and would Like to move all

  • 0

I Have a treeView Already populated (in vb.net) and would Like to move all the nodes or all the Tree for this matter, to a Root node that Contains it all

I Have this:

Root1
---Water
---Dirt
-----Fire
-----Stone
---UFOs
Root2
---Acid
-----H20
-----TNT

And put all into one “Megaroot”

MEgaRoot
---Root1
------Water
------Dirt
--------Fire
--------Stone
------UFOs
---Root2
------Acid
--------H20
--------TNT

Maybe it is easy, but it is one of those days when i havo no idea how to approach to this.

Thank you all for the response

PROBLEM SOLVED:

Dim Counter As Integer = trvItems.Nodes.Count
Dim oldRoot As TreeNode
Dim newRoot = New TreeNode("Megaroot")
For i As Integer = 0 To Counter - 1
    oldRoot = trvItems.Nodes(0)
     trvItems.Nodes.Remove(oldRoot)
     newRoot.Nodes.Add(oldRoot)
Next i
newRoot.Expand()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:06:32+00:00Added an answer on May 20, 2026 at 11:06 pm

    You need to remove the old root from the tree so you can give it a new parent. Create a new root then add the old one to it. Like this:

        Dim oldRoot = TreeView1.Nodes(0)
        TreeView1.Nodes.Remove(oldRoot)
        Dim newRoot = New TreeNode("Megaroot")
        newRoot.Nodes.Add(oldRoot)
        TreeView1.Nodes.Insert(0, newRoot)
        newRoot.Expand()    '-- or ExpandAll()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I have a WPF TreeView that has three nodes, I would like
I would like to insert an image to a TreeView node label. I can't
I have treeview control with one level of parent and child nodes, each node
I have simple win32 application (not dialog box), and treeview in this application. All
I have a TreeView where all nodes are assigned the same ContextMenuStrip. When I
I have a treeview which contains, per node, a key and text. However, there
I have a treeView , and i want to know if some node can
I have a treeview in wpf and I load it ok is all done
I have treeview and a context menu that is shown for every node. One
I'm using Treeview, I have already found both of these functions and they work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.