Capture combobox changed event

This topic contains 2 replies, has 3 voices, and was last updated by  Dan Potter 2 years, 6 months ago.

  • Author
    Posts
  • #23930

    lemonade
    Participant

    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

  • #23948

    Don Jones
    Keymaster

    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.

  • #23973

    Dan Potter
    Participant

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

You must be logged in to reply to this topic.