S
Sudip_inn
Guest
suppose there is a one parent node called AAA and there are 3 child node called A1,A2,A3 under the node AAA.
now i want to change the order of the child node by dragging under the same parent node AAA.
i follow the code from this site Move Node in Tree up or Down
they first remove child node and add the same child node with different index
public static void MoveUp(this TreeNode node)
{
TreeNode parent = node.Parent;
TreeView view = node.TreeView;
if (parent != null)
{
int index = parent.Nodes.IndexOf(node);
if (index > 0)
{
parent.Nodes.RemoveAt(index);
parent.Nodes.Insert(index - 1, node);
}
}
else if (node.TreeView.Nodes.Contains(node)) //root node
{
int index = view.Nodes.IndexOf(node);
if (index > 0)
{
view.Nodes.RemoveAt(index);
view.Nodes.Insert(index - 1, node);
}
}
}
i do not want to remove child node rather i want to change the index or position of the node under same parent node....how it will be possible? please share a sample code. thanks
Continue reading...
now i want to change the order of the child node by dragging under the same parent node AAA.
i follow the code from this site Move Node in Tree up or Down
they first remove child node and add the same child node with different index
public static void MoveUp(this TreeNode node)
{
TreeNode parent = node.Parent;
TreeView view = node.TreeView;
if (parent != null)
{
int index = parent.Nodes.IndexOf(node);
if (index > 0)
{
parent.Nodes.RemoveAt(index);
parent.Nodes.Insert(index - 1, node);
}
}
else if (node.TreeView.Nodes.Contains(node)) //root node
{
int index = view.Nodes.IndexOf(node);
if (index > 0)
{
view.Nodes.RemoveAt(index);
view.Nodes.Insert(index - 1, node);
}
}
}
i do not want to remove child node rather i want to change the index or position of the node under same parent node....how it will be possible? please share a sample code. thanks
Continue reading...