Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8108461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:06:58+00:00 2026-06-06T01:06:58+00:00

I am trying to set selectedItem on a comboBox(mx). Following is the code :

  • 0

I am trying to set selectedItem on a comboBox(mx). Following is the code :

callLater(function ():void {
        if (comboBox.dataProvider && comboBox.dataProvider.length > 0) {
            comboBox.selectedItem = comboBox.dataProvider.getItemAt(0);
        }
});

EDIT : I am creating Comboboxes programatically :

var comboBox:ComboBox = new ComboBox();

This works fine and sets the selectedItem to the first item from the data provider – but ONLY if the combobox is displayed on the screen and not hidden within a collapsible group.

I have a situation where I may have the combobox enclosed within a Collapsible Group (my own component) and not displayed until the collapsed group is expanded (see images below)

First Image : When the groups are collapsed and combobox is not displayed but created
collapsed_groups

Second Image : when the collapsed group is expanded to display the combobox – notice that the first element in the dataprovider is NOT selected as selectedItem

Expanded Group

following line is ALWAYS executed

 comboBox.selectedItem = comboBox.dataProvider.getItemAt(0);

But the first item is not selected in the case when the combobox is enclosed in a collapsed group – works fine when the combobox is enclosed in an expanded group.

I think this is a bug in flex – unless someone thinks otherwise ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:07:00+00:00Added an answer on June 6, 2026 at 1:07 am

    The problem is that you can not know when the object is added to the stage. As you alread mentioned, the item will not be set if the component is not visible.

    Creation Complete is not called multiple times, therefore you need another way to do it.
    To make sure the item is set to the component after it is visible again, just call the ‘callLater’ method on the comboBox itself (Then the method is just called after the component has been rendered again, instead of you whole application)

    var comboBox:ComboBox = new ComboBox();
    
    comboBox.callLater(function ():void {
        if (comboBox.dataProvider && comboBox.dataProvider.length > 0) {
            comboBox.selectedItem = comboBox.dataProvider.getItemAt(0);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to bind a ListBox's SelectedItem data to a property. The following code
I am trying to move the following function listView_SelectionChanged away from code-behind and handle
I'm trying to set a combobox's dataprovider. I have 2 comboboxes: cb_div and cb_stores.
I have the following code that I'm trying to use to populate a ComboBox,
When trying to set DoMatchParen I get the following error: E492: Not an editor
I have: ComboBox.DataSource = System.Enum.GetValues(typeof(ImageLayout)); but how do I set the ComboBox.SelectedItem to an
I am trying to set selected item of comboBox on click event of DataGrid,
I'm trying to set seletected value to a pre-loaded combobox using silverlight with MVVM.
I am trying to set the selected item in my silverlight combobox from a
Im trying set the single table inheritance model type in a form. So i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.