tab form project practical questions

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
This topic is 3 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
zztemp
Posts: 42
Last visit: Mon Oct 02, 2023 10:51 pm
Answers: 1
Has voted: 2 times

tab form project practical questions

Post by zztemp »

Product: PowerShell Studio 2020 (64 Bit)
Build: v5.7.172
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.18363.0

So i developed a form application to help us out with our computer staging.
It creates AD computer objects within certain OU's and adds certain information to the objects.
This is when new employees are coming aboard.
Now i've been asked to create something similar but for when an employee changes department or subfirm.

I want to make a tab-application where tab1 = application 1 (create) and tab2 = application 2 (move).
My questions are:

1) can i simply copy over the GUI-objects and code into the new project?

2) from the testing and fooling around i've sorta got an idea on how to do this but, in your mainform.pfs the amount of code would become quite large.
Is there a way to have the code for tab1 en tab2 in separate files? Say, $tab1.onclick( dotsource tab1.ps1 ) , $tab2.onclick(dotsource tab2.ps1)
But then in a nicer way.

Best of wishes

S.
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: tab form project practical questions

Post by brittneyr »

You can copy and paste your objects from one form to another, but you will need to link all your events again to your objects. Depending on the complexity of your form, it might be easier to make a copy of the form and add it to your new project then modify as needed.

No, if you want this in separate files then you would need to separate your tabs into two forms.
Brittney
SAPIEN Technologies, Inc.
User avatar
zztemp
Posts: 42
Last visit: Mon Oct 02, 2023 10:51 pm
Answers: 1
Has voted: 2 times

Re: tab form project practical questions

Post by zztemp »

So what you're saying is, copy paste both your GUI-objects and all of your code into a new project and that should work?
separate your tabs into two forms
Hmm got any examples of that laying around?

I was thinking more in the lines of:
Say i have a project :
  • - Mainform.psf
    - Globals.ps1
    - Startup.PSS
    - AD.ps1 (this is code for one tab)
Instead of coding everything in Mainform.psf, i remember there being a trick with invoke. Something like 'Invoke-AD_ps1' or something. But i can't remember exactly how i did it (few years back).
So then i'd say, in the Mainform.psf $buttonthatsitsontab2.click{ Invoke-AD_ps1}

Is that an accepted method too ?
User avatar
brittneyr
Site Admin
Posts: 1649
Last visit: Mon Mar 18, 2024 1:47 pm
Answers: 38
Been upvoted: 30 times

Re: tab form project practical questions

Post by brittneyr »

If you just copy and paste your objects in the designer from one form to another, the objects (tab control, buttons, checkboxes, etc) will copy, but it will not know that click event $buttonthatsitsontab2.click is associated will the corresponding control. You will need to update the events for each of the controls from the Properties panel:
SPS_PropertiesPanelEvents.png
SPS_PropertiesPanelEvents.png (31.68 KiB) Viewed 6546 times
I cannot give you an example of that as the really depends on a case by case basis of how your code is structured. It would be possible to separate your business logic into separate ps1 file(s) from your form to slim down your forms, but again, this depends on how you have things set up.

If you have coding practice specific questions, please post in our PowerShell or PowerShell GUIs form.
Brittney
SAPIEN Technologies, Inc.
User avatar
zztemp
Posts: 42
Last visit: Mon Oct 02, 2023 10:51 pm
Answers: 1
Has voted: 2 times

Re: tab form project practical questions

Post by zztemp »

Gotcha, thank you!
This topic is 3 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.