2 Replies Latest reply on Jul 17, 2006 4:21 AM by Lu_BaoGuo

    ComboBox select Item

    MichaelDiederich Level 1
      Hi all,

      i have a combobox with n entities - and on init i want to select e.g. the second entity. I tried to use selectedItem, getChildAt and and and.. and it doesn't work.

      Please give me a hint how to get this working!


        • 1. Re: ComboBox select Item
          meticoolus Level 1
          I guess, your requirement is to select second element from combo box on page load .if I am not wrong.
          If my anticipation is right then,here i go,
          you just have to call the init method in Application tag using initialize or creationComplete.
          <mx:Application ...........initialize= "init();">
          (note: if initialize doesnt work use creationComplete = "init() )

          //define init method as
          function init()

          <mx:ComboBox id="comboID" ....../>


          Hope this is useful.
          • 2. Re: ComboBox select Item
            Lu_BaoGuo Level 1
            function preSetItemCombox(obj:Object,DefaultItem:String){
            var aDP:Array = mx.utils.ArrayUtil.toArray(obj.dataProvider);
            var sDataValueInit:String = DefaultItem;
            var sDataValueCur:String;
            for ( var i:Number=0; i<aDP.length; i++ ) {
            sDataValueCur = aDP .data;
            if ( sDataValueCur == sDataValueInit) {
            obj.selectedIndex = i;