Adobe Flex: Set Selected Item In ComboBox

Oddly, Flex does not let you set an item to be selected in its ComboBox component. While the selectedIndex property can be used, you would have to make your own method to loop through the ComboBox’s dataProvider contents to get the index. Luckily, someone saved us the trouble of creating our own component extending ComboBox. Use the code below to be used as a substitute component for mx:ComboBox.

To use this custom made ComboBox, if your component file is under the folder com/ui/ then you have to specify it in the xml namespace. Setting the item in the ComboBox to be selected can be done by calling the selectedValue property (see code below).

Related Posts Plugin for WordPress, Blogger...


  1. er, what does the error say? the code above does not compile correctly. you need to supply the correct data provider info (that will be used to retrieve data from the database) and the string_value should be replaced as well.

  2. doesn’t work for me either.

    i’m confused with the “STRING_VALUE”

    if fill the dataProvider is card.
    with the definition:

    public var cards:ArrayCollection = new ArrayCollection(
    [ {label:”Visa”, data:1},
    {label:”MasterCard”, data:2},
    {label:”American Express”, data:3} ]);

    how can i choose “MasterCard”?
    i fill selectedValue=”MasterCard”, but nothing happen

  3. Hope you are doing great… I have project in (web development) Flex ColdFusion and SQL. I need someone to work on that project from beginning to end. I want a person who I can email if there is a problem and the problem is fixed in 24 hour period. The project hasn’t started yet.
    But if you are interested then please let me know your hourly rate. I like the idea of invoice and will pay based on the same…
    This is for the person who can give attention to my project if not daily at least every other day…. So please think and let me know if interested…

Leave a Reply

Your email address will not be published. Required fields are marked *