Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to programatically set preselected Index? #68

Open
JegaJegatheesh opened this issue Jan 25, 2020 · 1 comment
Open

How to programatically set preselected Index? #68

JegaJegatheesh opened this issue Jan 25, 2020 · 1 comment

Comments

@JegaJegatheesh
Copy link

JegaJegatheesh commented Jan 25, 2020

This is my code,

dropDown.selectedIndex = selectIndexAt

But didn't works

@JegaJegatheesh JegaJegatheesh changed the title How to programatically set selected Index? How to programatically set preselected Index? Jan 25, 2020
@zzpaf
Copy link

zzpaf commented Nov 1, 2022

Just saw this and running into the same issue I did this to solve it:

dropDown.selectedIndex = 0
dropDown.text = dropDown.optionArray[dropDown.selectedIndex!]

The actual index does get selected with "selectedIndex" but it does not display the text in the field, this way you also get the text placed in the field.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants