views:

433

answers:

3

To select all the items in myList I wrote:

myList.selectedItems = ['red','cyan','magenta'] ;

But what if I don't know about the items in the mx:list in advance? How can I select all the items in a list without specifying their names?

Thanks

A: 

You may have luck accessing the child ListBaseContentHolder of the mx.controls.List. I've never done this myself and don't have the moment to test it, but that should be the object that contains the children of the List.

Tegeril
+1  A: 

You can use the selectedIndices property of the List component instead of the selectedItems property.

You should be able to loop through your dataset, pushing the indexes onto an array, then set selectedIndices to your array.

TandemAdam
For anyone stumbling on this question, I just searched for this now as I had to do something similar for the first time (specifically, selecting a certain set and limiting the max selected items), but this concept works, simply manipulate the selectedIndices array.
Tegeril
+1  A: 

How about

myList.selectedItems = (myList.dataProvider as ArrayCollection).source

??

I haven't tried this, but I have a feeling that this should probably work.. !!

Sai Prasad