1

I am trying to force uppercase in some ComboBox

<s:ComboBox id="cbStocks" width="200" height="30" fontSize="16" dataProvider="{this.knownSymbols}" />

I tried the setStyle approach suggested by flexexamples without success

cbStocks.setStyle( "typographicCase", TypographicCase.CAPS);

and

cbStocks.textInput.setStyle( "typographicCase", TypographicCase.CAPS);

both throw an exception

RangeError: Property typographicCase value caps is out of range

How do you force Uppercase in a ComboBox?

4

1 回答 1

2

You can create a custom formatter to achieve this:

public class CapsFormatter extends Formatter {

    override public function format(value:Object):String {
        return value ? value.toString().toUpperCase() : "";
    }

}

and then use it as follows:

<fx:Declarations>
    <f:CapsFormatter id="capsFormatter"/>
</fx:Declarations>

<s:ComboBox labelFunction="capsFormatter.format">
    <s:ArrayList>
        <fx:String>Hello</fx:String>
        <fx:String>world</fx:String>
    </s:ArrayList>
</s:ComboBox>
于 2013-02-13T09:46:12.033 回答