Link to home
Start Free TrialLog in
Avatar of Nalin Kumar Balaji Shanmugam
Nalin Kumar Balaji ShanmugamFlag for Ireland

asked on

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
Avatar of Nalin Kumar Balaji Shanmugam
Nalin Kumar Balaji Shanmugam
Flag of Ireland image

ASKER

Advance Thanx

Regards

Baaji
ASKER CERTIFIED SOLUTION
Avatar of rfgkev
rfgkev

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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