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"?>
<!-- http://blog.flexexamples.com/2007/12/19/alternating-item-colors-in-combobox-dropdown/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="top"
backgroundColor="white">
<mx:ComboBox id="comboBox"
alternatingItemColors="['red', 0x00FF00, '#0000FF']">
<mx:dataProvider>
<mx:Array>
<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:dataProvider>
</mx:ComboBox>
</mx:Application>
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 Responses to “Alternating item colors in ComboBox dropdown”
Leave a Reply