2 Replies Latest reply on Oct 24, 2008 1:19 PM by ntsiii

    Assigning value to Combo box

      I have populated combobox. 1-app,2-ball,3-ccccc.
      Now I got the data from database and have to assingh selected value to 2 to combo.
      How do I do that?
        • 1. Re: Assigning value to Combo box
          Gregory Lafrance Level 6
          myCbx.selectedIndex = 1;
          • 2. Re: Assigning value to Combo box
            ntsiii Level 3
            To fill in a bit on a common problem with ComboBox, notice that Greg shows you set the selectedIndex?

            You must almost always do it this way with ComboBox because selectedItem requires that the item be a reference to an item in the ComboBox dataProvider. This is rarely possible.

            Instead, if you want to set a ComboBox using the value in the dataProvider, you must loop over the dataProvider and compare the value You hav to the values in the appropriate item property. When you find a match, use the loopp index to set the selectedIndex.

            If your dataProvider is an array of primitive types like strings or numbers, then you *can* set selectedItem.