Capture combobox changed event

Struggling to find a starting point on how to capture a combobox change event.

All i’m looking to do is update combobox2, from the selection of combobox1 dropdown list. I.e. Select Accountant in combobox1 dropdown list, combobox2 automatically updates with OU Accounts.

Could anyone give me a starting point on how this should look?

Thanks

https://msdn.microsoft.com/en-us/library/system.windows.forms.listbox_events(v=vs.110).aspx covers the docs for the control; there’s a change* event. You bind it the same way you’d bing the Click event for a button. I’m not sure if you’re using PowerShell Studio; if you are, you should be able to right-click the control in the designer and add the code for the change event.

*Specifically, SelectedIndexChange or SelectedValueChange are probably what you want, depending on how the control’s behavior is configured.

$combobox1_SelectedIndexChanged = { write-host $combobox1.Text}