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.
User avatar
zztemp
Posts: 31
Joined: Mon Apr 03, 2017 6:58 am
Answers: 1
Has voted: 1 time

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: 653
Joined: Thu Jun 01, 2017 7:20 am
Answers: 8
Been upvoted: 7 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 Ryn
SAPIEN Technologies, Inc.

User avatar
zztemp
Posts: 31
Joined: Mon Apr 03, 2017 6:58 am
Answers: 1
Has voted: 1 time

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: 653
Joined: Thu Jun 01, 2017 7:20 am
Answers: 8
Been upvoted: 7 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 304 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 Ryn
SAPIEN Technologies, Inc.

User avatar
zztemp
Posts: 31
Joined: Mon Apr 03, 2017 6:58 am
Answers: 1
Has voted: 1 time

Re: tab form project practical questions

Post by zztemp »

Gotcha, thank you!