Confirmation box?

Archived support forum for customers who once purchased a PrimalForms product license. This forum is locked.
This topic is 11 years and 1 week 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.
User avatar
bheidemann
Posts: 19
Last visit: Mon Dec 09, 2013 9:11 am

Confirmation box?

Post by bheidemann »

How could I make a simple confirmation box? I have an action tied to a button but I would like the user to confirm the action before it takes place. Thank you
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Confirmation box?

Post by davidc »

You can use the messagebox:
PowerShell Code
Double-click the code block to select all.
if([System.Windows.Forms.MessageBox]::Show(\"Text\",\"Caption\") -eq \'OK\')
{
	#run script
}
PrimalForms 2011 & PowerShell Studio 2012 have a snippet called \"msgbox\" you can use.

David
David
SAPIEN Technologies, Inc.
User avatar
bheidemann
Posts: 19
Last visit: Mon Dec 09, 2013 9:11 am

Re: Confirmation box?

Post by bheidemann »

Where can I get more info on the message box? I like your example but there isn\'t a way for the user to cancel out of it.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Confirmation box?

Post by davidc »

One of the inputs to the message box allows you to specify the buttons to display:
PowerShell Code
Double-click the code block to select all.
if([System.Windows.Forms.MessageBox]::Show("Continue?", "Question",[System.Windows.Forms.MessageBoxButtons]::OKCancel) -eq "OK")
{
	Write-Host "OK!"
}
Here is the MSDN help for the messagebox:

http://msdn.microsoft.com/en-us/library ... .Show.aspx

David
David
SAPIEN Technologies, Inc.
This topic is 11 years and 1 week 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.