Styling a Flex 3 ComboBox control’s vertical scroll bars

The following example shows how you can style the vertical scroll bar on a ComboBox control in Flex 3 by setting the dropdownStyleName style and verticalScrollBarStyleName style.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/29/styling-a-flex-3-combobox-controls-vertical-scroll-bars/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white">

    <mx:Style>
        .myCustomComboBox {
            dropdownStyleName: myCustomDropdown;
        }

        .myCustomDropdown {
            fontWeight: normal;
            verticalScrollBarStyleName: myCustomVertScroll;
        }

        .myCustomVertScroll {
            trackColors: white, white;
            upArrowSkin: Embed("bullet_delete.png");
            downArrowSkin: Embed("bullet_add.png");
        }
    </mx:Style>

    <mx:Array id="arr">
        <mx:Object label="One" />
        <mx:Object label="Two" />
        <mx:Object label="Three" />
        <mx:Object label="Four" />
        <mx:Object label="Five" />
        <mx:Object label="Six" />
        <mx:Object label="Seven" />
    </mx:Array>

    <mx:Form>
        <mx:FormItem label="default:">
            <mx:ComboBox id="comboBox1"
                    dataProvider="{arr}" />
        </mx:FormItem>
        <mx:FormItem label="skinned:">
            <mx:ComboBox id="comboBox2"
                    dataProvider="{arr}"
                    styleName="myCustomComboBox" />
        </mx:FormItem>
    </mx:Form>

</mx:Application>

View source is enabled in the following example.

One thought on “Styling a Flex 3 ComboBox control’s vertical scroll bars

Comments are closed.