How to dynamically update combo box list content based on user input

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.
Post Reply
auseagle
Posts: 1
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Sat May 09, 2020 11:29 am

How to dynamically update combo box list content based on user input

Post by auseagle »

I am trying to create a multi layer dynamic combo box content based on user input.
First combo box will have a set list of values e.g. Physical, Virtual
I want to content of the second combo box to dynamically change the list of items based on user's selection from the first combo box. e.g. if they select Physical, then the second combo box will have a list containing Server#1, Server#2, Server#3. If the user selects Virtual from the first combo box, then the second one will now contain list like Server#10, Server#11, Server#12.
Further the third combo box will have further variable selections based on what Server# was selected in the second combo box etc.
Your help is much appreciated.

jvierra
Posts: 14368
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: How to dynamically update combo box list content based on user input

Post by jvierra »

You have to use the "SelectedIndexChanged" event to populate the second list.

Attached is a demo of how to populate a second control on a change to a ComboBox.
Attachments
Demo-Combobox.psf
(21.66 KiB) Downloaded 6 times

Post Reply