# ComboBox values color change based on "if" condition

**URL:** <https://forum.kirupa.com/t/combobox-values-color-change-based-on-if-condition/317408>\
**Category:** flash\
**Created:** [December 19, 2010, 3:24pm UTC](https://forum.kirupa.com/t/combobox-values-color-change-based-on-if-condition/317408 "2010-12-19T15:24:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajesh\_flash](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@rajesh\_flash](https://forum.kirupa.com/u/rajesh_flash)\
**Post date:** [December 19, 2010, 3:24pm UTC](https://forum.kirupa.com/t/combobox-values-color-change-based-on-if-condition/317408/1 "2010-12-19T15:24:13Z")

</div>

hello friends,

I need a small help from you guys. I am doing a simple combobox example. Now my requirement was, i want to differentiate the combobox values with some colors based on a condition.  
Suppose for ex: if my combobox data value exceeds 200 i want to display the items in “red” else i want to display in “green”. i need solutions for this requirment.

your help would be appreciated. i need it asap. kindly refer the attached image, that is what i am looking for. my output should look like that.

* * *

\<?xml version=“1.0” encoding=“utf-8”?\>  
\<!-- Simple example to demonstrate the Halo ComboBox control. --\>  
\<s:Application xmlns:fx="[[COLOR=#0066cc]http://ns.adobe.com/mxml/2009[/COLOR]](http://ns.adobe.com/mxml/2009)"  
xmlns:s=“library://ns.adobe.com/flex/spark”  
xmlns:mx=“library://ns.adobe.com/flex/mx”\>

```
&lt;fx:Script&gt;
    &lt;![CDATA[
        import mx.collections.ArrayCollection;
        import mx.events.DropdownEvent;
        
        [Bindable]
        public var cards:ArrayCollection = new ArrayCollection(
            [ {label:"Value1", data:100}, 
                {label:"Value2", data:200}, 
                {label:"Value3", data:300},
                {label:"Value4", data:400}, 
                {label:"Value5", data:500}]);
        
        private function closeHandler(evt:DropdownEvent):void {
            myLabel.text = "You selected: " + ComboBox(evt.target).selectedItem.label;
            myData.text = "Data: " + ComboBox(evt.target).selectedItem.data;
        }
    ]]&gt;
&lt;/fx:Script&gt;

&lt;s:Panel title="Halo ComboBox Control Example" 
         width="75%" height="75%"
         horizontalCenter="0" verticalCenter="0"&gt;
    &lt;s:HGroup left="10" right="10" top="10" bottom="10"&gt;
        &lt;mx:ComboBox dataProvider="{cards}" width="150" 
                     close="closeHandler(event);"/&gt;
        
        &lt;s:VGroup width="250"&gt;
            &lt;s:Label width="200" color="blue" text="Select a type of credit card."/&gt;
            &lt;s:Label id="myLabel" text="You selected:"/&gt;
            &lt;s:Label id="myData" text="Data:"/&gt;
        &lt;/s:VGroup&gt;
    &lt;/s:HGroup&gt;
&lt;/s:Panel&gt;

```

\</s:Application\>

* * *

Rajesh
