advtreeview: interaction copy: copied node placed as first, should be last

Hi,
I drag&drop in tdmcopy.
The selected node is copied, in my case in the same parent
The new node is placed in the first position, I like it to be placed at the bottom as last node of this parent.
Is this selectable?
Clipboard:
Can you give me a hint how to put a node (with subnodes) on he clipboard and how to paste?
tcmfull, right key gives no responce....

Hi, we'll investigate this here as soon as possible.

Hi,

You can implement the OnBeforeDropNode event and set ACanDrop to False.
Then you can manually choose the insert position with the following code:

procedure TForm1.AdvTreeView1BeforeDropNode(Sender: TObject; AFromNode,
  AToNode: TAdvTreeViewVirtualNode; var ACanDrop: Boolean);
begin
  ACanDrop := False;
  AFromNode.Node.CopyTo(AToNode.Node, AToNode.Node.Nodes.Count);
end;

Hi,

Nice…

But… because the node is not dropped, my afterdropnode- code is skipped.

Here is essential code.

With regards,

Jac van Megen

image002.jpg

Yes, but you can move the code from the OnAfterDropNode to the OnBeforeDropNode after you set the index. This is basically what happens inside the treeview.

Hi,

To quick on my side.

A can call the afterdropnode and that solves (so far I can see now) the problem.

But then a new problem appears:

On the position of the node that was copied the now is new node;

At the bottom is the node the original node is placed.

I hope you understand what I mean.

With regards,

Jac van Megen

image002.jpg

I give every node a tag with the identity (autoinc) of the record in the table. And there it shows this problem

image002.jpg

Hi,

Please look at gif to see what happens.

With kind regards,

Jac van Megen

image002.jpg

It's unclear to me what exactly is you are demonstrating. Note that when copying a node, the Tag is also copied, which means that the original node and the new node will have the same Tag.

Good morning,

Yes, I understand. (now)

After the copy I need to access the new node in order to give this node a new tag.

I altered the original node tag

I tried to find the new node with AToNode.GetLastChild.node.Tag;

But this results in the aFromNode.Tag

How do I get to the new Node, in order to update the tag with the autoinc from the table?

With regards,

Jac van Megen

image002.jpg

Hi,

If you automatically add it to the end, then you can access the new node with:

procedure TForm1.AdvTreeView1BeforeDropNode(Sender: TObject; AFromNode,
  AToNode: TAdvTreeViewVirtualNode; var ACanDrop: Boolean);
var
  newNode: TAdvTreeViewNode;
begin
  ACanDrop := False;
  AFromNode.Node.CopyTo(AToNode.Node, AToNode.Node.Nodes.Count);
  newNode := AToNode.Node.Nodes[AToNode.Node.Nodes.Count - 1];
  newNode.Tag := 999;
end;

Hi,

Thank you, you’ve been very helpful.

When I copy to the root aToNode = Nil, so in this case you need ACanDrop=true;

So you need this:

if AvtDelen.Interaction.DragDropMode = tdmCopy then

begin

if AtoNode <> nil then

begin

ACanDrop := false;

AFromNode.Node.CopyTo(AtoNode.Node, AtoNode.Node.Nodes.Count);

AvtDelenAfterDropNode(Sender, AFromNode, AToNode);

end;

end;

It seems to be working now.

Thanks again.

With regards,

Jac van Megen

image002.jpg

Thanks for the feedback!