4 Replies Latest reply on Dec 14, 2010 5:52 AM by BhaskerChari

    how to change the color for combobox values based on condition

    Rajeshb_Flash

      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. I dont know how to do this. can you guys pls help me out on this. 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.

       

      -------------------------

      <?xml version="1.0" encoding="utf-8"?>
      <!-- Simple example to demonstrate the Halo ComboBox control. -->
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx">
         
          <fx:Script>
              <![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;
                  }
              ]]>
          </fx:Script>
         
          <s:Panel title="Halo ComboBox Control Example"
                   width="75%" height="75%"
                   horizontalCenter="0" verticalCenter="0">
              <s:HGroup left="10" right="10" top="10" bottom="10">
                  <mx:ComboBox dataProvider="{cards}" width="150"
                               close="closeHandler(event);"/>
                 
                  <s:VGroup width="250">
                      <s:Label width="200" color="blue" text="Select a type of credit card."/>
                      <s:Label id="myLabel" text="You selected:"/>
                      <s:Label id="myData" text="Data:"/>
                  </s:VGroup>
              </s:HGroup>
          </s:Panel>
         
      </s:Application>

       

      --------------

      waiting for your replies.

      Rajesh