Alternating item colors in ComboBox dropdown

The following example shows how you can set alternating item/row colors in a ComboBox control’s dropdown menu by setting the alternatingItemColors style using MXML, ActionScript or CSS

Full code after the jump.


<?xml version="1.0" encoding="utf-8"?>
<!-- -->
<mx:Application xmlns:mx=""

    <mx:ComboBox id="comboBox"
            alternatingItemColors="['red', 0x00FF00, '#0000FF']">
                <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" />


View source is enabled in the following example.

You can also set the alternatingItemColors style in an external style sheet or <mx:Style /> block, using the following snippet:

ComboBox {
    alternatingItemColors: #FF0000, #00FF00, #0000FF;

Or you can set the alternatingItemColors style using ActionScript, as seen in the following snippet:

comboBox.setStyle("alternatingItemColors", ["red", 0x00FF00, "#0000FF"]);

0 thoughts on “Alternating item colors in ComboBox dropdown