5/2/2010 10:40:33 PM
Title:
drag and drop
Hi,
I have two list boxes, whenever i doubleclick or click the first list box element , it will moves to the other list box, and there is select all option is also there, So whenever select all option it will moves into other list box and vice versa. please provide any examples
Thanks & Regards,
K.V.Ramakrishna
5/3/2010 5:59:30 AM
hi you can see this example to add items from one list component to another on click. in this example the Item from first list component is removed and added to the next .Here is the source code for example:
<?xml version="1.0"?>
<!-- dpcontrols/ListLabelFunction.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script><![CDATA[
import mx.events.ListEvent;
protected function list1_changeHandler(event:ListEvent):void
{
//add item to second list
forList2.addItem(forList1.getItemAt(event.rowIndex));
//remove added item from list1 item to second list
forList1.removeItemAt(event.rowIndex)
}
]]></mx:Script>
<mx:ArrayCollection id="forList1">
<mx:source>
<mx:Object label=" Item one " data="Item one data"/>
<mx:Object label=" Item two " data="Item two data"/>
<mx:Object label=" Item three " data="Item three data"/>
</mx:source>
</mx:ArrayCollection>
<mx:ArrayCollection id="forList2">
</mx:ArrayCollection>
<mx:List id="list1" dataProvider="{forList1}" change="list1_changeHandler(event)" />
<mx:List id="list2" dataProvider="{forList2}" />
</mx:Application>
5/3/2010 9:40:34 PM
Hi,
Thanks for the reply, whenever I click All button , The list of all elements will move to other component, how to do that, please give me the reply
5/3/2010 10:29:55 PM
to add all items to the other list you can write the following code on a button click function. I have used the above code by Caldwell
forList2.source=forList1.toArray();
forList1.removeAll();