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.

 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

One Response to Styling a Flex 3 ComboBox control’s vertical scroll bars

  1. Junior says:

    Hello! Nice post! how can i made if I wish to change te scrollbar width? is it possible?
    Thanks!

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree