Helpful Information
Home
Categories
Contact us
Category: Apache Flex
Design - add to combo box
How do I add options to a combo box? The first one I'm working with will be a Yes/No. Radio button or check boxes are not an option in this case.
As no one seem to know how to do this, and I just found out how, I'll post the solution. There are two, but I don't know the other one yet.
<mx:FormItem id="householdExceptionsLabel"
label="Household Exceptions"
top="35" right="5"
horizontalAlign="right">
<mx:ComboBox
id="householdExceptionsData"
width="75">
<mx:dataProvider>
<mx:ArrayCollection>
<mx:String>Yes</mx:String>
<mx:String>No</mx:String>
</mx:ArrayCollection>
</mx:dataProvider>
</mx:ComboBox>
</mx:FormItem>
Found the second way. This involves using a script.
This is the control:
<mx:FormItem id="householdExceptionsLabel"
label="Household Exceptions"
top="32" right="5"
horizontalAlign="right">
<mx:ComboBox id="householdExceptionsData"
width="75"
dataProvider="{englishYesNo}" />
</mx:FormItem>
This is the script:
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
[Bindable]
private var englishYesNo:ArrayCollection =
new ArrayCollection([
"Yes",
"No"]);
...
for (i=0;i<1;i++)
{
householdExceptionsData.dataProvider[i] = englishYesNo[i];
householdTANFData.dataProvider[i] = englishYesNo[i];
}
There is a language test that uses either the spanishYesNo (not shown) or the englishYesNo variable.
Hope this is helpful to anyone else.
privacy (GDPR)