2 Replies Latest reply on May 25, 2009 3:07 AM by *Prashant Shelke*

    How to remove all items from list control?


      Hello All,


      I am using list control to display some data. I want to remove all items from it after clicking button.

      How to do it?

      Please help.



      Thanks and Regards,

        • 1. Re: How to remove all items from list control?
          Patel Bharat Level 2

          Hi Swati,


          As i understand of the problem, you want don't want to show any item in list control when you press a button. For that you just have to set the list control data provider as a null.


          For your reference I am giving the code bellow:





          <?xml version="1.0" encoding="utf-8"?>



















                              * This method will remove all items from list component



                              private function onRemoveClick(aEvent:MouseEvent) : void






                                   listID.dataProvider =









               <mx:VBox width="100%" height="100%">


                    <mx:List id="listID" width="35" >

                         <mx:Object label="AL" data="Montgomery"/>

                         <mx:Object label="AK" data="Juneau"/>

                         <mx:Object label="AR" data="Little Rock"/>



                    <mx:Button label="Remove" click="onRemoveClick(event)"/>


















          With Regards

          Bharat Patel

          • 2. Re: How to remove all items from list control?
            *Prashant Shelke* Level 4

            Hi Swati,

            Here is simple way to do what you want:// if the dataProvider is ArrayCollection


            You have to avoid just making it null, because by making null is not candidate for Garbage Collection.