4 Replies Latest reply on Jun 25, 2008 6:03 AM by flexBeginner2008

    ComboBox setStyle on list

      Can anyone tell me please how do I set the color of list texts in a combobox?

      Thank you
        • 1. Re: ComboBox setStyle on list
          Gregory Lafrance Level 6
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
          <mx:ComboBox color="red">
          • 2. Re: ComboBox setStyle on list
            flexBeginner2008 Level 1
            Yes, indeed, but I want the text on the header to be on one color, and the labels of the list elements from the dropdown on another one. Can I do this from ActionScript?

            Thanks again
            • 3. Re: ComboBox setStyle on list
              Gregory Lafrance Level 6
              ----------------- classes/MyComboBox.as -------------------
              package classes
              import mx.collections.ArrayCollection;
              import mx.controls.ComboBox;
              import mx.events.DropdownEvent;
              import mx.events.FlexEvent;

              public class MyComboBox extends ComboBox {
              private var arr:Array = ["Fish", "Meat", "Veggies", "Candy", "Plastic"];
              private var ac:ArrayCollection = new ArrayCollection(arr);

              public function MyComboBox() {
              addEventListener(FlexEvent.CREATION_COMPLETE, completeHandler);
              addEventListener(DropdownEvent.OPEN, openHandler);
              addEventListener(DropdownEvent.CLOSE, closeHandler);
              this.dataProvider = ac;

              private function completeHandler(e:FlexEvent):void{
              private function openHandler(e:DropdownEvent):void {
              this.setStyle('color', 'red');

              private function closeHandler(e:DropdownEvent):void {
              this.setStyle('color', 'blue');
              --------------- Test.mxml -------------------------
              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="init()">
              import classes.MyComboBox;

              private var myCB:MyComboBox = new MyComboBox();
              private function init():void{
              • 4. Re: ComboBox setStyle on list
                flexBeginner2008 Level 1
                Great! This is what I was looking for.

                Thank you very much for your help