[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $form = new-object Windows.Forms.Form $button = new-object Windows.Forms.Button $button.Dock = "fill" $button.Text = "Click to exit" ################################### # DELEGATE SUPPORT ################################### $button.add_click( { write-host @" `$this is a handle to the button: $this" $($this | out-string) ===================================== `$_ is a pointer to MouseEventArgs: $_ $($_ | out-string) "@ $form.close() } ) $form.Add_Shown( {$form.Activate() } ) $form.controls.add($button) $form.showDialog()