Link to home
Start Free TrialLog in
Avatar of Angela4eva
Angela4eva

asked on

Vb.net two dropdown one function

Protected Sub ddlManagers_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlManagersTop.SelectedIndexChanged, ddlManagersBottom.SelectedIndexChanged

dosomething(ddlManagersTop.SelectedItem.Text)

 End Sub

I have one function for two dropdown selected index changed events,
Now above code workd only if the selection in Top dropdown changes but not working for the botton drop down.
How can I make it work for both the dropdowns/
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do both dropdowns set the dropdownstyle to dropdownList. If the user can type free text into the box then sometimes the index does not change and hence the event does not trigger.
I'm guessing the above should be ComboBox rather than DropDownList--it's been so long since I've done WinForms. The concept is the same; change the class accordingly.   = )
add
Dim ddl As <your control type> = DirectCast(sender, <your control type> )
dosomething(ddl.selecteditem.text)
<your control type> is whatever control you want/need. i.e. button, combobox, etc.