Page 1 of 1

Change combobox selected item based on selected item of another combobox

Posted: Tue Mar 17, 2020 10:40 am
by MoneySolver
I'm looking for assistance on the logic for the following. Please read this request carefully as a lot of people misunderstand what I'm asking.

I have two comboboxes that are already pre-populated with items (powershell objects).
I want the second combobox's selected item to be determined based on what is chosen in the first combobox

Example:
Combobox 1 Items (job titles): helpdesk,sales,servicing
helpdesk.manager = "john smith"
sales.manager = "Mary Jane"
servicing.manager = "jesse custer"

combobox 2 items (managers): john smith,mary jane,jesse custer

if user selects helpdesk in combobox 1, i want combobox 2 to automatically change to john smith.

Re: Change combobox selected item based on selected item of another combobox

Posted: Tue Mar 17, 2020 11:40 am
by MoneySolver
This is solved. I stumbled across the findstring method which returns the index number. I then can put that into the combobox.selectedindex property. from my testing, I can only leverage the selectedindex property. trying to set the selectedtext gives weird and inconsistent results. on top of that, if the dropdown style is set to dropdownlist then you can't set selectedtext at all.

This is what worked for me.
$cmbbx_Manager.SelectedIndex = $cmbbx_Manager.FindString($cmbbx_Role.SelectedItem.manager)