Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [reflection.assembly]::loadwithpartialname(“System.Windows.Forms”) | Out-Null
- [reflection.assembly]::loadwithpartialname(“System.Drawing”) | Out-Null
- $form = New-Object Windows.Forms.Form
- $form.text = "PowerShell WinForms Example"
- $label = New-Object Windows.Forms.Label
- $label.Location = New-Object Drawing.Point 50,30
- $label.Size = New-Object Drawing.Point 200,15
- $label.text = "Enter your name and click the button"
- $textfield = New-Object Windows.Forms.TextBox
- $textfield.Location = New-Object Drawing.Point 50,60
- $textfield.Size = New-Object Drawing.Point 200,30
- $button = New-Object Windows.Forms.Button
- $button.text = "Greeting"
- $button.Location = New-Object Drawing.Point 100,90
- $button.add_click({
- $label.Text = "Hello " + $textfield.text
- })
- $form.controls.add($button)
- $form.controls.add($label)
- $form.controls.add($textfield)
- $form.ShowDialog()| Out-Null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement