Hello, i had dataprovider loaded from database, and this selected
label is saved on database in other table. But when user must edit
your data how i initialize the combobox on edit form with selected
item in you previous selected item?
I try this, but i don't know it is the best way:
public function
setComboItem(event:Event,item:String):void{
for(var i:Number = 0; i <
event.target.dataProvider.length; i++)
{
if(event.target.dataProvider[i] ==
item){
event.target.selectedIndex = i;
}
}
}
<mx:FormItem label="Estado Civil:" width="470">
<mx:ComboBox id="cbEstadoCivil"
creationComplete="setComboItem(event,objCurriculo.estado_civil)">
<mx:ArrayCollection>
<mx:String>solteiro</mx:String>
<mx:String>casado</mx:String>
<mx:String>separado</mx:String>
<mx:String>divorciado</mx:String>
<mx:String>viúvo</mx:String>
<mx:String>união estável</mx:String>
</mx:ArrayCollection>
</mx:ComboBox>
</mx:FormItem>