Search code examples
drop-down-menuflex4

Flex 4: Add Items to a dropdownlist progmatically


I would like to add items to a dropdownlist progmatically.

I have an empty drop downlist and depending on a number of factors I then populate it with various action choices.

the Drop Down list is called dlFirstChoice and I would like to add some values to it, can some one give me the basic code to do so, I have tired ILists and Arrays as the Dataprovider but clearly Im doing something wrong.

Please and thank you in advance for any help.


Solution

  •  var dropListDb:ArrayList=new ArrayList();
         dropListDb.addItem({label: "Equals (List)"});
         dropListDb.addItem({label: "Is Between"});
         dlFirstChoice.visible = true;
         dlFirstChoice.dataProvider=dropListDb;
         dlFirstChoice.selectedIndex=0;