| Flex 2 Developer's Guide >
Building User Interfaces for Flex Applications > Using Data-Driven Controls > List control |
|||
The List control displays a vertical list of items. Its functionality is very similar to that of the SELECT form element in HTML. It often contains a vertical scroll bar that lets users access the items in the list. An optional horizontal scroll bar lets users view items when the full width of the list items is unlikely to fit. The user can select one or more items from the list.
|
NOTE |
|
The HorizontalList, TileList, DataGrid, Menu, and Tree controls are derived from the List control or its immediate parent, the ListBase class. As a result, much of the information for the List control applies to these controls. |
For complete reference information, see List in Adobe Flex 2 Language Reference.
The following image shows a List control:
The List control has the following default sizing properties:
|
Property |
Default value |
|---|---|
|
Default size |
Wide enough to fit the widest label in the first seven visible items (or all visible items in the list, if there are less than seven), and seven rows high, where each row is 20 pixels high. |
|
Minimum size |
0 |
|
Maximum size |
5000 by 5000 |
If you specify horizontalScrollPolicy="on", the default width of a List control does not change; it is still large enough to display the widest visible label. If you set horizontalScrollPolicy="on", and specify a List control pixel width, you can use the measureWidthOfItems() method to ensure that the scroll bar rightmost position corresponds to the right edge of the content, as the following example shows. Notice that the additional 5 pixels ensures that the rightmost character of the text displays properly.
<mx:List width="200" id="li2" horizontalScrollPolicy="on"
maxHorizontalScrollPosition="{li2.measureWidthOfItems() - li2.width +
5}">
The preceding line ensures that the rightmost position of the scroll bar puts the end of the longest measured list item near the right edge of the List control. Using this technique, however, can reduce application efficiency, so you might consider using explicit sizes instead.
Lists, and all subclasses of the ListBase class determine their sizes when a style changes or the data provider changes.
If you set a width property that is less than the width of the longest label and specify the horizontalScrollPolicy="off", labels that exceed the control width are clipped.
Flex 2.01