The following example shows how you can customize the ComboBox control’s text input styles by setting the textInputStyleName style in Flex.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/21/customizing-the-flex-combobox-controls-text-input-styles/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white">

    <mx:Style>
        ComboBox {
            textInputStyleName: myCustomTextInputStyleName;
        }

        .myCustomTextInputStyleName {
            color: red;
            fontStyle: italic;
            fontWeight: bold;
        }
    </mx:Style>

    <mx:ApplicationControlBar dock="true">
        <mx:Form styleName="plain">
            <mx:FormItem label="editable:">
                <mx:CheckBox id="checkBox"
                        selected="false" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>

    <mx:ComboBox id="comboBox"
            editable="{checkBox.selected}"
            creationComplete="comboBox.open();">
        <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.

 
Tagged with:
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

3 Responses to Customizing the Flex ComboBox control’s text input styles

  1. Sergiy says:

    Why this is not working in Flex Builder 2 (2.0.1)?
    Is this only for FB3?

  2. Kevin says:

    Question: I like the ComboBox to have the both the Left and Right sides curved like they currently appear when the ComboBox is NOT editable, but my goal is to make it look the same when the ComboBox is EDITABLE. Is this possible in either Flex 2 or 3? I have both, but I do not see the function to make it happen.

  3. buddy says:

    Hi Peter,

    I m working on flex 4. This might not be right ques for this blog. but i m facing problems with checkbox within combobox. I m using arcardio’s component. But still not yet satisfied.

    Do u have any solution Plzzz..

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree