Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
New Developer
Posts: 34
Registered: ‎03-23-2011
My Device: Bold 9700
My Carrier: Rogers

Setting the selectedItem of a DropDown based on the label

I have a dropdown that is populated with a dataprovider containing 3 fields. Then I want to change the selectedItem (and label obviously) based on the user's saved settings.

 

The saved settings are strings from a DB.  dp.getItemAt(0).currency is the saved variable.

 

This is what I've been trying to no avail:

 

var myObj:Object = new Object();
myObj.label = dp.getItemAt(0).currency;
drpCurrency.selectedItem = myObj;

 

Any suggestions?

 

Developer
Posts: 508
Registered: ‎01-19-2011
My Device: My Trusty Red Plane
My Carrier: Outer Space

Re: Setting the selectedItem of a DropDown based on the label

write a for-loop going through all your items in the dataprovider? as soon as you have the correct label, use break and set the selected item based on the loop-counter, i'd say

-----------------------------------------------------------------------
I'm a bird from outer space. But I'm not flappy o.o
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Setting the selectedItem of a DropDown based on the label

To echo @pyth, Objects are by reference and not by value. Items have to reference the actual object that was originally added to the data provider.