Skip to content

Instantly share code, notes, and snippets.

@jclosure
Created January 16, 2015 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jclosure/b3c7b3c8e455533de1fb to your computer and use it in GitHub Desktop.
Save jclosure/b3c7b3c8e455533de1fb to your computer and use it in GitHub Desktop.
Use PowerShell to Create WinForms on the Fly
$firstName = New-Object System.Windows.Forms.textBox
$firstName.add_KeyUp({ $fullName.Text = $firstName.text + " " + $lastName.text})
$lastName = New-Object System.Windows.Forms.textBox
$lastName.top += 50
$lastName.add_KeyUp({ $fullName.Text = $firstName.text + " " + $lastName.text})
$fullName = New-Object System.Windows.Forms.textBox
$fullName.top += 100
Add-Type -AssemblyName System.Windows.Forms
$form = New-Object System.Windows.Forms.Form
$form.Text = "My First Form"
$form.controls.add($firstName)
$form.controls.add($lastName)
$form.controls.add($fullName)
$form.Add_Shown({ $form.Activate()})
$form.ShowDialog()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment