1 Reply Latest reply on Nov 3, 2006 7:18 AM by peterent

    Flex2 Listbox problem

    wintechmedia Level 1
      Hi

      I am new to Flex2 and have seen in Flex 1.5 a method for Listbox AddItem() which in flex 2 is not there for Listbox component. I would like to know if there is any method to add items in listbox of flex2 (Not through dataprovider that is a slow process).

      Cheers!
      Rohit
      -----------------------------------------
      www.wintechmedia.com
        • 1. Re: Flex2 Listbox problem
          peterent Level 2
          The *only* way to add items to a List control in Flex 2 is through its dataProvider. That was actually true, too, in Flex 1.5. The list.addItem() method was a short-cut for list.dataProvider.addItem() - the list never added items to itself. We deliberately separate the model (data) from the view (list control). It is one of the corner stones of Flex.

          [Bindable] private var dp:ArrayCollection = new ArrayCollection( .... );

          <mx:List dataProvider="{dp}" ... />

          dp.addItem( ... ) ; will add the new item to the end of the list.