2 Replies Latest reply on Aug 22, 2008 2:12 AM by Mitek17

    ComboBox. Need Help!

    masita18 Level 1
      Hi, I got a comboBox and wanted to fill it with item text retrieved from the database on the dropdown list. Am able to put all the items in the dropdownlist. But when I tried to set the selecteditem to be displayed on the comboBox programmatically; it sometimes can work and sometimes cannot work. Had trace the value that was set to the selecteditem of the combobox and the value was correct. Appreciate if you could advise if there is anything that I may miss out on the settings of the comboBox. Had also tried to put a fixed string to the selecteditem and it also has the same problem. Am showing the code below.
        • 1. Re: ComboBox. Need Help!
          Rob Rusher Level 1
          The ComboBox is displaying a bunch of objects. So when you use selectedItem, you get the object. Likewise, when setting with the selectedItem, it is going to look for that exact object. (note: two object with the same values are still not the same object; look at the uid that is generated for it)

          My guess is that you are trying to preselect a value in the combobox, use this BindableComboBox:
          • 2. Re: ComboBox. Need Help!
            Mitek17 Level 1
            There is a bunch of problems in ComboBox related to the selectedItem.

            In your particular case the problem is you are setting the selectedItem property independently from the dataProvider.
            Designers of the ComboBox forgot that in the event-driven structure you can't rely on the fact that you are setting dataProvider first and then selectedItem.

            As a quick fix I would do the dataProvider assignment in the same place where you assign selectedItem. Or place selectedItem binding into the MXML (but then you will run unto another problem, that selectedItem=null does not deselect ComboBox)

            Here is more accurate solution to this problem: