Clear form in PSScriptPad

Hello, Is there a way to have Button to Clear (remove all entries) from the form in PSScriptPad?

Tool: Visual Studio, Visual Studio Code, PSScriptPad, PowerShell Module

Hello @isolo,

You could define a button to execute a function when it is clicked. The function you create would need to have all of the controls individually reset (one-by-one) or otherwise configured to suit your tastes (examples below). Some forms will use a method like Clear (e.g. TextBox) and other forms will need a method specific to that control (e.g. the ‘CheckState’ property of a CheckBox control).

$Checkbox1.CheckState = ‘Unchecked’
And so forth

Note: If you switch between (PSScriptPad for the UI placement) and (VS Code for the “wiring up” of the code) then you can benefit from the Intellisense capabilities when adding methods to your controls.