views:

215

answers:

4

HI, How do i retreive the total number of items (count) of a combo box in Flex?

A: 

Try using:

combobox.collection.length

where combobox is the combobox you are using

I'm not sure this will work though. You may need to subclass the control because collection is a protected member :(

George Edison
A: 

The dataprovider of combobox is an arraycollection. You can use the length property to count the number.

michael
Wrong! It's a write-only property.
George Edison
Maybe, it is not clear. My meaning is the length property of the arraycollection.
michael
`dataprovider` is a write-only property.
George Edison
A: 

random idea for you:

var dp : Object = combobox.dataProvider ;
if(dp is Array)
{
    //do something cool
}
else if(dp is ArrayCollection){
    //do something equally as cool
}

etc...

jeremy.mooer
"Something cool" would have been dp.length
adamcodes
+1  A: 

I've confirmed that this will work:

(comboBox.dataProvider as ArrayCollection).length
houser2112