3 Replies Latest reply on Dec 11, 2007 12:37 AM by Mike B Baker

    ComboBox add new item to the list

      Hi all
      I am trying to figure out how does one add new item to the combobox.
      I have a combobox which has datasource from database, and I want to add "All" as the first item in the combobox list. So say the database table returns the list:
      "Dog", "Cat", "Horse"
      But what I want in the combobox list:
      "All", "Dog", "Cat", "Horse"

        • 1. Re: ComboBox add new item to the list
          rkoe123 Level 1
          Hi all

          I need to use addChildAt(), but being new to Flex 2, can anyone kindly show me how to use the method?

          I have a compile error when I have:

          var s:String = new String("All");

          seems like the first paremeter being type DisplayObject doesn't like String
          • 2. Re: ComboBox add new item to the list
            Hello rkoe123,
            How about to use a "Label" as the DisplayObject? Or something to be coverted to the "IUICompoent"?
            • 3. Re: ComboBox add new item to the list
              Mike B Baker Level 1

              You can add the 'ALL' to your dataProvider here is an example,
              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" initialize="initData()">
              import mx.collections.*;
              public var animalArray:ArrayCollection;

              public function initData():void {
              animalArray=new ArrayCollection(
              [{label:"CAT", data:"CAT"},
              {label:"DOG", data:"DOG"},
              {label:"HORSE", data:"HORSE"}]);



              <mx:ComboBox id="animalComboBox" dataProvider="{animalArray}"/>


              Hope this helps,