How do I preselect an item in a dropdown list

Avatar

Avatar
Validate 1
Level 1
Ian_Kensey
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
Ian_Kensey
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
Ian_Kensey
Level 1

09-02-2016

Hi,

I need to preselect an item in a drop down list, but I cannot see how to achieve this using the current or existing methods.  I know that if I set the rawValue then it works, but later when I try to retrieve the data from the selected dropdown list item, I get an "Empty" which doesn't help.  What it needs is the value,label pair to work correctly. When I manually select an item from the drop down list it works perfectly. But not when I try programtically set it. So now I am wondering if it is possible to set the index for the drop down list, so that it believes it has an item selected, so when I poll it I get the correct value.

Hope you can help.

Kind Regards,

Ian

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Springboard
MVP
Magus069
MVP

Likes

143 likes

Total Posts

1,078 posts

Correct reply

155 solutions
Top badges earned
Springboard
Validate 1
Ignite 3
Ignite 1
Establish
View profile

Avatar
Springboard
MVP
Magus069
MVP

Likes

143 likes

Total Posts

1,078 posts

Correct reply

155 solutions
Top badges earned
Springboard
Validate 1
Ignite 3
Ignite 1
Establish
View profile
Magus069
MVP

09-02-2016

Hi there,

You can use the selectedIndex property to set the value wanted.

And to retrieve a value, I recommend you to use *.getDisplayItem(*.selectedIndex);

I hope this will help!

Answers (1)

Answers (1)

Avatar

Avatar
Validate 1
Level 1
Ian_Kensey
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
Ian_Kensey
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
Ian_Kensey
Level 1

10-02-2016

Hi Magus069,

That worked brilliantly.  I don't know why I didn't spot it the first time round.

Thanks

Ian