1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
using assembly System.Windows.Forms using namespace System.Windows.Forms $form = [Form] @{ Text = 'Mi formulario' } $listBox = [ListBox] @{ Location = New-Object System.Drawing.Point(10,40) Size = New-Object System.Drawing.Size(260,40) Height = 150 } [void] $listBox.Items.Add('1') [void] $listBox.Items.Add('2') $button = [Button] @{ Text = 'Pulsar y mostrar elemento seleccionado' Size = New-Object System.Drawing.Size(260,40) } $button.add_Click{ Write-Host $listBox.SelectedItem $form.Close() } $form.Controls.Add($listBox) $form.Controls.Add($button) $form.ShowDialog() |
