how to enable/disable control on different form

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 11 years and 2 weeks 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.
Locked
User avatar
dafinch
Posts: 8
Last visit: Wed May 01, 2019 4:27 am

how to enable/disable control on different form

Post by dafinch »

I have a project i'm working on in Powershell Studio 2012. I have two forms. I have a control on the main form that by default is disabled. The second form is a preference list. What i'm trying to do is if I change one of the selections on the preference form have the control on the main form be enabled. I can't seem to figure out how I can reference that control to enable it before I close out the second form.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: how to enable/disable control on different form

Post by jvierra »

In PowerShell there is no interform communication. You can only display and work with one form at a time. You can pass arguments to a new form for it to use when it is displayed but once the new form is displayed the calling script cannot execute until the that form is closed.
User avatar
dafinch
Posts: 8
Last visit: Wed May 01, 2019 4:27 am

Re: how to enable/disable control on different form

Post by dafinch »

Thats what it was afraid of, I found documentation on how to do it from C#.

Is there some type of event I can leverage when I return to the first form so I can check for these setting changes I make. I'm writing these prefences to the registry so they are persistant.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: how to enable/disable control on different form

Post by jvierra »

PowerShell and Forms are not capable of creating classic programs because they do not support more than one thread. Many of the things you will need to do for a classic Forms based program cannot be done with PowerShell.

PowerShell is fro scripting. It is not a way for a non-programmer to build programs.

You can build simple utilities with PowerShell and do some very nice things but the learning curve is steep for non-programmers.

With PowerShell we can build large projects with multiple forms very easily however some things still cannot be done. All forms in PowerShell Studio are 'Modal'. That means that once a form is displayed all script execution that started the form will be blocked until the form is closed. One form can call another and pass variables but that script will be blocked until the called form is closed.

The form object can be queried after it is closed. It contains all changes and selections.

Please read the blog posts on how to use controls with PowerShell Studio as most if not all of these questions will be answered.
This topic is 11 years and 2 weeks 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.
Locked