03-11-2020 09:52 PM - edited 03-11-2020 09:56 PM
Hi everyone,
So, I have a tab control here, and I want to reorder the controls inside the tab control's page. Normally, we would just Right-click the tab -> Reorder Controls in Page (normal way). But now I would like to try the other way to reorder the controls using the Reorder Controls in Page Method in VI Scripting
.
Initially, the order in page 0 is
But now I want it to be
I tried the program I designed as attached above. But it wouldn't change the control's order in the specific page of the tab unless I use the normal way. I used the ControlIndex and Class Name of the control to check the order of the control.
Anyone can help? Thanks a lot!! 😀
03-11-2020 11:02 PM
I think the problem is that you are running the VI script on itself. You need to use a separate VI with the script to act on a non-running VI that has the controls you want to reorder.
If you look at the Detailed Help of the Reorder Controls method, then you'll see it says "Settable when the VI is running = NO"
03-12-2020 01:56 AM
Hi Benny,
Ravens is right!
"You need to use a separate VI with the script to act on a non-running VI that has the controls you want to reorder."
A bit OOT... try the VI in the snippet below & let me know how it works. For me, it crashed LV2016 at the SaveVI method.
03-12-2020 03:29 AM - edited 03-12-2020 04:00 AM
Thanks for replying and I got the way to change the order. I did it on another VI (Reorder_Tab_Control.vi) using VI scripting and got it worked. For now, I'm just trying to get the idea, so I hard-coded it.
But I still need to go in the tab control and manually right-click->reorder controls first, only then I can reorder the controls in the Reorder_Tab_Control.vi. Is there any way to avoid that, I prefer to reorder the controls in here(Reorder_Tab_Control.vi) without accessing the tab control VI manually.
03-12-2020 03:56 AM
Hi parthabe,
It works fine on LabVIEW 2019, no crash happened.
But I'm wondering now why I needed to manually reorder tab controls first then only I could reorder using the program (VI attached in my previous comment). Any suggestion or idea to avoid touching the tab control, reorder it using the program instead of manually right-click and reorder it.
It would be lovely if it is workable. 😀
03-12-2020 08:43 AM - edited 03-12-2020 08:45 AM
It worked fine for me as is. Are you sure you needed to "manually" change first?
I see an issue with your VI. You are closing the references to the items in a random order. You should close the references in the reverse order you opened them. Also, only your last control is being closed because of the tunnel type (last element vs. indexing). But that said, it is not always necessary to close references.
One other suggestion. Index Array is expandable by dragging the bottom border. No need to copy it and split the array wire.
03-12-2020 11:07 PM
Could you test my code as it is, because the tab in my snippet has 4 pages, whereas am seeing only 2 in your VI.
03-13-2020 08:40 AM
Your snippet doesn't have any tab or any specific number of pages. Yours is just the reordering code.
03-13-2020 11:33 AM
Oh I'm sorry! I should have said that the VI that the scripting VI calls, has a Tab control with 4 Pages.
03-15-2020 08:49 PM - edited 03-15-2020 09:22 PM
Now it works fine, but I redesigned the code to also change the orders of controls on the 2nd page while remains the 1st-page control's order and it failed.
This is the result:
before
after
What I expect it should be something like this
In my example here, the controls order will only change on page 1 and page 2 remains. Next, I manually open the Tab Control VI and right-click>Reorder Controls, then I try to run the reorder VI again. Now the changes of the control order made on page 2, and page 1 remains.
I believe the problem is the Reorder Controls Method is specified for 1 page. Therefore, when changes made on one page, the previous or other page control's order will be overwritten and stay behind to whatever the order that has been made newly.
Or maybe anyone has a better understanding of the problems stated above.