How can I get the "ok" button on a popup box to close the form?
Product, version and build: 5.6.165
32 or 64 bit version of product: 64
Operating system:
32 or 64 bit OS: 64
*** Please add details and screenshots as needed below. ***
DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
Popup Message Box to close form
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION 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.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION 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.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Popup Message Box to close form
Add a click event to your "ok" button and in that event, use your form object to call the method Close(). For example:
- $form.Close()
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
-
- Posts: 12
- Last visit: Wed Mar 06, 2024 5:29 am
Re: Popup Message Box to close form
This is actually on a pop-up dialogue box:
Add-Type -AssemblyName "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
[void][System.Windows.Forms.MessageBox]::Show('mytext!', 'Attention!') # Casting the method to [void] suppresses the output.
Not sure where in this code to make this happen
Add-Type -AssemblyName "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
[void][System.Windows.Forms.MessageBox]::Show('mytext!', 'Attention!') # Casting the method to [void] suppresses the output.
Not sure where in this code to make this happen
Re: Popup Message Box to close form
Well without any other context to what is your are trying to accomplish overall, if you want to close the form when the user hits ok on the messagebox, then you shouldn't be setting the output to void. Do something like the following:
Code: Select all
if('Ok' -eq [System.Windows.Forms.MessageBox]::Show("Message Text", "Title",'OKCancel')){
write-host "You pressed OK"
$form.Close()
}else{
write-host "You pressed Cancel"
}
Brittney
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.