After sent data to a GridView (Out-GridView)
How can I create a event that handle row-click (row-select)
Or a event that handles double-click and closes the GridView
providing the selected rows in a variable
TIA
Unfortunately I don't think there is a 'row select event' for Out-GridView, or a way to double-click an item in the list.
However, this example shows how to select items from an array using an Out-GridView. Pipe your data through the Out-GridView CmdLet and use the -PassThru switch to allow the user to select items. PassThru implies -Wait which suspends the script and waits for the user to select items, or close the window:
$viewme = @('pick','one','of','these')
$selection = $viewme | Out-GridView -PassThru -Title 'Pick item(s)'
If I click Cancel or close the window, the $selection variable is null:
$selection -eq $null
True
Otherwise if I do select items, they are returned in an object of type System.Array:
$selection
one
these
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With