L
lallous
Hello
I'm new to C# language and wonder if the code is correct syntax wise but not
necessarily logic wise.
private void nodeMoveUp(TreeView tv)
{
TreeNode tn = tv.SelectedNode;
if (tn == null || tn.Index == 0)
return;
int newindex = tn.Index - 1;
TreeNode newnode = (TreeNode) tn.Clone();
if (tn.Parent != null)
tn.Parent.Nodes.Insert(newindex, newnode);
else
tv.Nodes.Insert(newindex, newnode);
tn.Remove();
tv.SelectedNode = newnode;
}
Is the usage of .Clonse() to duplicate a node and then insert it into the
treeview correct?
My aim is to move a selected node directly to the position above it, while
the node above it will go down and take its place.
Regards,
Elias
I'm new to C# language and wonder if the code is correct syntax wise but not
necessarily logic wise.
private void nodeMoveUp(TreeView tv)
{
TreeNode tn = tv.SelectedNode;
if (tn == null || tn.Index == 0)
return;
int newindex = tn.Index - 1;
TreeNode newnode = (TreeNode) tn.Clone();
if (tn.Parent != null)
tn.Parent.Nodes.Insert(newindex, newnode);
else
tv.Nodes.Insert(newindex, newnode);
tn.Remove();
tv.SelectedNode = newnode;
}
Is the usage of .Clonse() to duplicate a node and then insert it into the
treeview correct?
My aim is to move a selected node directly to the position above it, while
the node above it will go down and take its place.
Regards,
Elias