'combobox updated by another combobox' question

Ask your PowerShell-related questions, including questions on cmdlet development!
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 1 year and 10 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
monderick
Posts: 7
Last visit: Thu Jan 18, 2024 7:44 am
Answers: 1
Has voted: 1 time

'combobox updated by another combobox' question

Post by monderick »

Hello, I've read some examples of the combobox 'SelectedIndexChanged' function but struggling to understand if the code should so in the form selection area of the first combobox or the second one.
My script is for deploying new VMs and now has the task of determining the memory allocation based upon job role. I just need the SelectedIndex of the second combobox to update whenever a selection is made in the first comboxbox. I'm likely overcomplicating this

Code: Select all

$VMType_Combo_SelectedIndexChanged =
	{
		If ($VMType_Combo.selectedtext -eq "non-developer") { $Mem_Combo.SelectedIndex = 1 }
		If ($VMType_Combo.selectedtext -eq "developer") { $Mem_Combo.SelectedIndex = 5 }
	}
thanks for any guidance offered
by monderick » Fri Apr 22, 2022 10:59 am
found my error in case anyone else stumbles on this and was missing a line to actually update the second combobox

Code: Select all

$VMType_Combo_SelectedIndexChanged =
	{
		If ($VMType_Combo.text -eq "non-developer") {$Mem_Combo.SelectedIndex = "1" }
		Else { $Mem_Combo.SelectedIndex = "5" }
	}
	$VMType_Combo.add_SelectedIndexChanged($VMType_Combo_SelectedIndexChanged)
	
	
Go to full post
User avatar
monderick
Posts: 7
Last visit: Thu Jan 18, 2024 7:44 am
Answers: 1
Has voted: 1 time

Re: 'combobox updated by another combobox' question

Post by monderick »

found my error in case anyone else stumbles on this and was missing a line to actually update the second combobox

Code: Select all

$VMType_Combo_SelectedIndexChanged =
	{
		If ($VMType_Combo.text -eq "non-developer") {$Mem_Combo.SelectedIndex = "1" }
		Else { $Mem_Combo.SelectedIndex = "5" }
	}
	$VMType_Combo.add_SelectedIndexChanged($VMType_Combo_SelectedIndexChanged)
	
	
This topic is 1 year and 10 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