PrimalForms/PowerShell – Event Behavior: Button Click and Switch Tab

I decided that I would post how to code a few Event Behaviors that could be coded with PowerShell using PrimalForms. You could just use your basic PowerShell Editor but PrimalForms is just my tool of choice.

So I start with a basic form (Two Tabs and a Button)

Then on the Events tab of $button1, double click ‘click’

Add the following code to the Event handler:

 $handler_button1_Click={
#TODO: Place custom script here
     If ($tabpage1.Visible -eq $true) {
          $tabcontrol1.SelectTab(‘tabpage2’)
     }
     ElseIf ($tabpage2.Visible -eq $true) {
           $tabcontrol1.SelectTab(‘tabpage1’)
     }
}

Clicking the button switches from tab to tab. Way cool!