Flex ComboBox, default value and dataproviders

mmattax picture mmattax · Aug 29, 2008 · Viewed 30.9k times · Source

I have a Flex ComboBox that gets populated by a dataprovider all is well...

I would now like to add a default " -- select a item --" option at the 0 index, how can I do this and still use a dataprovider? I have not seen any examples of such, but I can't imagine this being hard...

Answer

Theo picture Theo · Aug 30, 2008

If you don't need the default item to be selectable you can use the prompt property of ComboBox and set the selectedIndex to -1. That will show the string you set propmt to as the selected value until the user chooses another. It will not appear in the list of options, however.