0 Replies Latest reply on Oct 1, 2007 11:03 AM by aceinc

    How do you set the selected item of a combobox?

    aceinc Level 1
      I looked around and didn't find an intrinsic method or function to set the selected index of a combobox. I wrote a function, but I thought I would see what the "best" way of doing it is?

      The function I wrote is;

      private function setComboSelectedItem(cmbBoxIn:ComboBox,strFindItem:String):void
      {
      for (var i:int=0;i<cmbBoxIn.dataProvider.length;i++)
      {
      if (cmbBoxIn.dataProvider(I) == strFindItem)
      {
      cmbBoxIn.selectedIndex = i;
      break;
      }
      }
      }

      The parentheses surrounding "i" above should be square brackets, but they do not display.
      Paul