Topic: treeview moving parent

Hi,

is there some example when i move parent in treeview that child move with parent

Post's attachments

Attachment icon Screenshot_10.png 47.19 kb, 16 downloads since 2025-02-16 

Re: treeview moving parent

move nodes at the same level
https://myvisualdatabase.com/forum/view … 545#p32545

Re: treeview moving parent

Hi all

This version of the program has two examples in one.
Dmitry's example and my example.


My example allows you to move a node with or without child nodes to any new location in the tree. Does not use any additional table columns. Control using the mouse pop-up menu.
Something like this.

Post's attachments

Attachment icon TreeView change position-m.rar 12.64 kb, 38 downloads since 2025-02-17 

Re: treeview moving parent

Hi Sparrow,
I've always thought that being unable to move rows (and their children) from one node to another was a big weakness but this code has improved the functionality of 'treeview' considerably.
Thanks for sharing,
Derek.

Re: treeview moving parent

Hi Derek.

There is nothing complicated about moving a node. Just change the ParentID of one record and that record, and if there are child records, will change its binding. At first I tried to do it for a long time using mouse dragging. The solution was not simple and not universal. I did not show it. Now I changed the approach and did it through the pop-up menu. I'm glad if it is useful.

Re: treeview moving parent

Hi Igor, Sparrow,
Attached is an example of a ''treeview'' with functionality to move nodes (including children) by drag and drop (click and hold down the mouse on the node you want to move, drag it to its new position and then release the mouse).
I think Jean and Adam use ''treeviews'' quite a lot so maybe they (and others) will find this useful.
Derek.

Post's attachments

Attachment icon treeview drag and drop nodes.zip 441.95 kb, 42 downloads since 2025-02-19 

Re: treeview moving parent

Hello Sparrow, Hello Derek
Both methods for moving nodes in a TreeView are equal.
I tested Sparrow's: it works well but the manipulation seems more complex (I'll try to modify it to work only with shortcuts). To be tested!
Derek's is much simpler, it's the classic Drag'Drop as I like it. In addition, I find it faster
Thanks to both of you for these two approaches
JB

Re: treeview moving parent

Hi Derek, Jean


I want to warn you that my example and Derek's example have a critical error.
When specifying a target for moved nodes in the child record below, the moved nodes disappear. ParentID refers to nodes within itself.
I will fix it in my example soon.

Re: treeview moving parent

Hi Sparrow, Jean,
I had the same problem but thought that I'd fixed it in the script (Line24 - "if (form1.edit3.value <> form1.edit1.value)" to stop the ParentID being set to the ID and the node disappearing).
Any chance you can give me a 'step by step' example of the problem you've found as I can't re-create it and then I can try to correct it.
Thanks for your help,
Derek.

Re: treeview moving parent

derek wrote:

(Line24 - "if (form1.edit3.value <> form1.edit1.value)" to stop the ParentID being set to the ID and the node disappearing).
Derek.

The problem occurs when a node with child records is moved and one of the child records is selected as the target for moving.
Let's say the fifth row is moved along with its child rows, the sixth and seventh.
If you specify the sixth or seventh as the insertion location, the problem will occur.

Re: treeview moving parent

Hi Sparrow,
Yes, I see the problem now.
I'll have a look later on and see if it can be fixed.
Thanks,
Derek.

Re: treeview moving parent

Corrected and supplemented version of the example.
Removed unnecessary code and elements.
Fixed errors, added new ones. wink

Post's attachments

Attachment icon TreeView ch pos-fix.rar 10.25 kb, 41 downloads since 2025-02-19 

Re: treeview moving parent

derek wrote:

Hi Sparrow,
Yes, I see the problem now.
I'll have a look later on and see if it can be fixed.
Thanks,
Derek.

Derek look at one more thing. If the tree is larger than the height of the TreeView component.

Re: treeview moving parent

Hi all,


With Derek's permission, here are two versions of the example of dragging tree nodes with the mouse in one archive.
Derek's corrected version and my version. Both versions do the same job. wink Hopefully without any major errors this time.

Post's attachments

Attachment icon TreeView Der sp.rar 120.99 kb, 52 downloads since 2025-02-20 

Re: treeview moving parent

Hey Sparrow,
No permission needed - it's good when we can all exchange ideas on the Forum and make suggestions to each others' projects.  Everyone wins.
I really like the ''scrolltree'' procedure that you've added - I was looking at the problem but didn't manage to find a fix.
Thanks for your interest and input.
Derek.

Re: treeview moving parent

Hi Guys,
Thank you very much for tree nodes drag n drop....
Santa arrived to MVD bit late but still truly appreciated the Gift.....

Adam
God... please help me become the person my dog thinks I am.

Re: treeview moving parent

sparrow wrote:

Hi all,


With Derek's permission, here are two versions of the example of dragging tree nodes with the mouse in one archive.
Derek's corrected version and my version. Both versions do the same job. wink Hopefully without any major errors this time.


Hi Sparrow,
If I'm not doing something wrong, cannot move node up and down on same level. Moved node goes as a child.

Adam
God... please help me become the person my dog thinks I am.

Re: treeview moving parent

HI Adam


Perhaps you are talking about moving WITHIN ITS NODE (changing the location)? Yes, that is not the case.
Our solutions with Derek for moving between nodes and changing the binding in the database.


For changing the PLACE WITHIN ITS NODE I gave the link above.


If we are talking about different things, can we take a look at your example?

Re: treeview moving parent

sparrow wrote:

HI Adam
....

For changing the PLACE WITHIN ITS NODE I gave the link above.

...

Thanks... It would have been great if it could be done both. However, what you guys have done truly appreciated...


I got the script you refer. I originally asked to Dmitry for the script - moving nodes on same level.
I get it work sometimes OK sometimes not.


For instance, the attached sample project I couldn't get it working. I checked syntax etc., but couldn't find the cause of failure.

Post's attachments

Attachment icon qTester1.zip 117.65 kb, 17 downloads since 2025-03-12 

Adam
God... please help me become the person my dog thinks I am.

Re: treeview moving parent

The database table did not contain any values in the record_count column.

Post's attachments

Attachment icon qTester1 fix.zip 118.37 kb, 21 downloads since 2025-03-12 

Re: treeview moving parent

Thank you very much........


I tried to browse db using SQL Lite Studio but couldn't locate the value you have added in the record_count column. I'm fairly ignorant on using SQL Lite Studio.


I guess Issue is caused by old project I was trying to use.

Adam
God... please help me become the person my dog thinks I am.

22 (edited by sparrow 2025-03-12 20:35:17)

Re: treeview moving parent

I added values 1...4
https://myvisualdatabase.com/forum/misc.php?action=pun_attachment&amp;item=10894

Post's attachments

Attachment icon tbl.jpg 12.92 kb, 9 downloads since 2025-03-12 

Re: treeview moving parent

Hi Sparrow,


Thank you very much for the info.

Adam
God... please help me become the person my dog thinks I am.