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 4 years and 11 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.
Setting a variable in an event only defines the variable in the event. YOU cannot retain the value. It works the same for a function. Variables defined in a function or set in a function do not exists after the function ends. This is tru or all PowerShell scripts.
PowerShell Studio automatically generates return variables for the child form controls. It uses the following naming convention for the return variables:
$ChildFormName_ControlName
The easiest way to determine if the variable is correct is by hovering over it. If PowerShell Studio displays the type information, then you have to correct variable name. You can also use PowerShell Studio's PrimalSense. Press $ and the return variables will be included in the variable list.
Here is a related article (The function verbs used are outdated):
Yes - I know that but that was not your original question. The variables defined in the child form are available in the calling form as defined but it you assign them to a new variable in an event then the new variable will not be available outside of the event. Just use the child defined variables. There is no need to redefine them.
You should not do this:
$LocAdmin = $ChildForm_SetAdmin
It is unnecessary and the new variable will not be visible to the whole form.
This topic is 4 years and 11 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.