Display Combobox entries

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 4 years and 9 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
SQLHarry2
Posts: 12
Last visit: Tue May 05, 2020 7:21 am

Display Combobox entries

Post by SQLHarry2 »

Hi,

Looking for any inputs.

We are making one textbox for entering server name in the UI.
Based on the textbox entry we are searching for severnames and populating a combox box.

After search is complete user has to go and select drop down button to see the entries and select the necessary entry.

Instead, once search is complete, is there a way to Display all the entries that are populated in in combo box so that user dont need to drop down inorder to see the list.

Thanks
Harry
User avatar
Alexander Riedel
Posts: 8488
Last visit: Tue Apr 16, 2024 8:42 am
Answers: 20
Been upvoted: 37 times

Re: Display Combobox entries

Post by Alexander Riedel »

[Moved by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8488
Last visit: Tue Apr 16, 2024 8:42 am
Answers: 20
Been upvoted: 37 times

Re: Display Combobox entries

Post by Alexander Riedel »

Not knowing what the rest of your UI is like, the obvious way is to use a list ctrl rather than a combo box.
A combo box is generally used to allow a user to choose from a preset number of values for settings or further processing rather than to display results.
Alexander Riedel
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Display Combobox entries

Post by jvierra »

Just set the ComboBox "DropDownStyle" property to "Simple" and it will display all of the entries like a ListBox.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Display Combobox entries

Post by jvierra »

You can also just do this after loading the CB:

$combobox1.Items.AddRange(@('aaa','bbb','ccc','ddd'))
$combobox1.DroppedDown = $true
User avatar
SQLHarry2
Posts: 12
Last visit: Tue May 05, 2020 7:21 am

Re: Display Combobox entries

Post by SQLHarry2 »

PERFECT.
That is the exact step.

Thank you jvierra.
This topic is 4 years and 9 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