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 29
| Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$form = New-Object System.Windows.Forms.Form
$form.Text = 'Titre'
$form.Size = New-Object System.Drawing.Size(500, 200)
$form.StartPosition = 'CenterScreen'
$labelDescription = New-Object System.Windows.Forms.Label
$labelDescription.Text = "Ce script permet de choisir ce que vous souhaitez effectuer"
$labelDescription.Location = New-Object System.Drawing.Point(20, 20)
$labelDescription.AutoSize = $true
$labelDescription.Font = New-Object System.Drawing.Font("Arial", 11, [System.Drawing.FontStyle]::Bold)
$form.Controls.Add($labelDescription)
$ComboBox = New-Object System.Windows.Forms.ComboBox
$ComboBox.Location = New-Object System.Drawing.Point(20, 50)
$ComboBox.DropDownStyle = [System.Windows.Forms.ComboBoxStyle]::DropDownList
[void]$ComboBox.Items.Add("Choix 1") # Ajoute 1 item
$ComboBox.Items.AddRange(@("Choix 2", "Choix 3")) # Ajoute plusieurs items
$form.Controls.Add($ComboBox)
[void]$form.ShowDialog() # Affiche la fenêtre et attend sa fermeture
$choix = $ComboBox.SelectedItem
Write-Host "La sélection : $choix"
Read-Host |