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 5 years and 5 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.
PowerShell Studio 2018 v5.5.153
OS is windows 10 x64
We have a form that has a pcname text box. you can enter a machine name and then press any number of buttons to get and do stuff. But if the tech did not enter a name in the pcname text but I want a message to display in the richtextbox. I wrote this function which works with one issue. it throws up an error "Unhandled exception has occurred in a component in your application." But if I use RETURN or END the $error1 message is displayed but it still executes the rest of the code under the "button click" and displays that in the richtextbox and we don't want that. If the PCNameBox is emply I want the code to stop but I want the form to stay open.
Windows forms are event driven. When an event exits the code is stopped (no longer being executed) the form will not execute code until another event is received.
If you are in a loop that you want to end just exit the loop with a "break" statement.
To be sure a value has been entered for a pc name use the "validating" and "validated" events. Disable all buttons when the textbox is blank and enable all when it is "validated".
This topic is 5 years and 5 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.