11-26-2019 03:28 AM
When I choose a item in tree structure and click 'move down' button, sometimes item will move down one step and sometimes it will move two times? How can I resovle it?
Thank you very much!
11-26-2019 03:35 AM
Try to save the VI for a previous LabVIEW version. Not many users have LabVIEW 2019 installed.
11-26-2019 03:49 AM
Ok, I have saved to LabVIEW 2015.
11-26-2019 03:59 AM - edited 11-26-2019 04:02 AM
Your problem is in the Moving - you're leaving "New Parent" empty which means whatever you select to move will always become a top-level item, and moving the position to +2 from the existing row number (which doesn't care about indentation/parents).
As a result, the behaviour depends on if you select a parent or a child, and conceivably on the number of children (your example only has single number of children per entry, but it could be more complicated I guess).
I couldn't find a simple way to do this (although there may be one) - if there isn't you'll need to consider the "Indent Level" property and probably do some parsing based on the actual layout.
Some question that might be needed to move forward:
If you can describe the desired behaviour, it should be possible to achieve, but it might be a little more complicated than the implementation you have right now...
There are "Get Next Item" and "Get Previous Item" methods in the Invoke Node that will probably help. (edit, guess you might not care about get previous, but if you wanted to move up too...)
11-26-2019 04:19 AM
Hello sir,
Thank you for your Reply.
I only want to move the top Level(parent). This is a simple demo and I have realized the child Level move.
But I found that if I move the top Level, sometimes item will move one step, but sometimes it will move two steps.
11-26-2019 06:58 AM
As a brief reference, the 2015 version is not the same as the 2019 version for other readers (particularly those without 2019 to compare).
The possibly key point is that you want to provide a target "New Position" value at the level of the "New Parent" - i.e. root/parent level.
So you want to know the current parent level, and then add two (because it places it above that element, not in that element - probably you already knew this based on your original code).
The following works, at least when you only click "Move" for parent level items. If you don't change the items in the tree, you should build the parent/root/top-level list before running the While loop. If you want to do this at each level, you could compare the Indent Levels for equal to the ÄctiveItemTag value you're initially setting.
For children, you can use something like the following to either disallow or find parents (or do something else, etc)
Traverse until you have no more parents (i.e. it is the top level) then take the input value. If you select a top-level item, this gives an empty string on the first try and so returns the same string that you input.