ComboBox中的Flex Force大写

时间:2013-02-13 09:35:25

标签: flex combobox uppercase

我试图在某些ComboBox中强制大写

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

我尝试了flexexamples建议的setStyle方法,但没有成功

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


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

都抛出异常

RangeError: Property typographicCase value caps is out of range

如何在ComboBox中强制使用大写?

1 个答案:

答案 0 :(得分:2)

您可以创建自定义格式化程序来实现此目的:

public class CapsFormatter extends Formatter {

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

}

然后按如下方式使用它:

<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>