Show all elements in comboBox – Flex

So, while I was doing some Flex coding, I came across comboBox that had about 10 entries. What bothered me was the fact that Flex in default will only show 5 elements in a comboBox drop down. With rowCount setting we can specify how many elements we want to show. So if we want to show 10 elements in a comboBox we just say comboBox=”10″.

For example of how this works check out the app in the link below.

Flex Application that shows rowCount in action

So we have an array of 9 US cities. In the first comboBox we have just 5 elements visble. If we want to show them all, we can just specify rowCount=’9′. Even nicer solution is not to hand code the number of entries, but just tell Flex that comboBox shows all elements that are in cities array, we can do that by rowCount = “{cities.length}”. Notice those curly braces around cities.length? We have to use them because we are using ActionScript inside the braces, this way Flex knows that it has to evaluate the code inside curly braces and then send the result as the argument for rowCount.

Below is the sourcecode of this simple application (it is an image – since does not allow me to input whole Flex appcode in the post).



, ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: