Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerShell Out-GridView handle Click/DoubleClik event

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

like image 805
ZEE Avatar asked Oct 22 '25 16:10

ZEE


1 Answers

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
like image 118
mjsqu Avatar answered Oct 25 '25 05:10

mjsqu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!