1 | initial version |
To retrieve all outputs from a PowerShell form's dynamic checkbox list, you can follow these steps:
$selectedItems = @()
$checkBoxes.Add_CheckedChanged({
$checkBox = $this # current checkbox
$item = $checkBox.Text # get the text of the checkbox
if ($checkBox.Checked) {
$selectedItems += $item # add the item to the selected items array
} else {
$selectedItems -= $item # remove the item from the selected items array if it was unchecked
}
})
$selectedItems
array:Write-Host "Selected items: $($selectedItems -join ', ')"