Powershell GUI. Selecting an item from a dynamic ListBox.

Hello @sanyaman90,

If I understood you correctlly, you need to capture the value that user selects from the ListBox, so you could pass that value to your function and perform search. ListBox control has a property called SelectedItem, here is example in PowerShell not C#.

The problem with your code is that although your variable name is $ListBox, actual object is TextBox not ListBox

#TextBox Object Creation

$ListBox = New-Object System.Windows.Forms.TextBox

#ListBox Object Creation

$ListBox = New-Object System.Windows.Forms.ListBox

Hope that helps.