Listbox Question

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

Listbox Question

Post by mqh77777 »

I have a simple form. 1 button and 1 Listbox. The code on my button is this:

$button1_Click={
$Query = "SELECT * FROM CIM_VideoControllerResolution"
$res = Get-WMIObject -query $Query | Select Caption # | Out-GridView -Title "Resolution options"
}

I commented out the Gridview but if I remove this comment I do get all of my data as expected. I then try to load this list box and I've tried both of these methods.
Load-ListBox $listbox1 $res -Append
Load-ListBox $Listbox1 $res 'Resolution'

Neither one will enter date into the ListBox. How come?
User avatar
mqh77777
Posts: 252
Last visit: Mon Feb 26, 2024 10:07 am
Has voted: 1 time

Re: Listbox Question

Post by mqh77777 »

I got it. I was placing my Load-Listbox in the wrong place. when I place it within the BUTTON code it works. :D
This topic is 7 years and 4 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked