August 2nd, 2014

PowerTip: Wire Up PowerShell GUI Buttons

Doctor Scripto
Scripter

Summary: Learn to use the OK and Cancel buttons in a Windows PowerShell GUI.

Hey, Scripting Guy! Question How can I use Windows PowerShell to get my GUI’s OK and Cancel buttons to trigger when
           the user presses ENTER or Escape?

Hey, Scripting Guy! Answer Assign the OK and Cancel button objects to your form’s AcceptButton and CancelButton properties:

$form.AcceptButton = $OKButton
$form.CancelButton = $CancelButton

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.