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.
Locked
User avatar
SQLHarry2
Posts: 12
Joined: Fri Sep 08, 2017 1:34 pm

Display Combobox entries

Post by SQLHarry2 » Thu Jun 20, 2019 11:56 am

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: 7001
Joined: Tue May 29, 2007 4:43 pm

Re: Display Combobox entries

Post by Alexander Riedel » Thu Jun 20, 2019 12:05 pm

[Moved by moderator]
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
Alexander Riedel
Posts: 7001
Joined: Tue May 29, 2007 4:43 pm

Re: Display Combobox entries

Post by Alexander Riedel » Thu Jun 20, 2019 12:08 pm

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.

User avatar
jvierra
Posts: 13681
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Display Combobox entries

Post by jvierra » Thu Jun 20, 2019 12:44 pm

Just set the ComboBox "DropDownStyle" property to "Simple" and it will display all of the entries like a ListBox.

User avatar
jvierra
Posts: 13681
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Display Combobox entries

Post by jvierra » Thu Jun 20, 2019 12:49 pm

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
Joined: Fri Sep 08, 2017 1:34 pm

Re: Display Combobox entries

Post by SQLHarry2 » Thu Jun 20, 2019 1:22 pm

PERFECT.
That is the exact step.

Thank you jvierra.

Locked