Removing the First Inserted TreeNode in the Tree Without removing the Child

In the Below For loop i am Inserting a Treenode First ( at the Time of adding Node "TreeviewParent.Nodes.Add(Node)" the value of Node.Nodes.Count=0. After that when i insert a childnode below the Treenode I defined. Then i want to remove the Node. How can i remove the Parent

For Each dr In drs
       Node = New TreeNode
       Node.Text = dr(FieldName)
       TreeviewParent.Nodes.Add(Node)
       cnode = New TreeNode
       cnode.Text = dr(FieldName)
       Node.Nodes.Add(cnode)
       cnode.Parent.Remove()
Next
LVL 3
NalinkumarbalajiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NalinkumarbalajiAuthor Commented:
Advance Thanx

Regards

Baaji
rfgkevCommented:
Let's see if i've got this right.

You want to add a node to a tree. Add children to that node then remove the node but leave the children on the tree?

If you remove a treenode, all of it's child nodes go with it. the only way to remove the node while leaving the children on the tree would be to move the children to another node.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
Do you want to remove the parent node and take the orphaned child node and move it up one level?

If this is the case, what should happen to all the siblings of the node being moved up the tree hierarchy?

Do they get moved up as well or do they get deleted?

a
   b1
      c1
      c2
      c3
   b2
      d1
      d2
      d3

In the above tree, if we remove the parent of b1, should we end up with this:

b1
   c1
   c2
   c3

Or this:

b1
   c1
   c2
   c3
b2
   d1
   d2
   d3
 
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.