簡體   English   中英

SelectedLabel spark ComboBox

[英]SelectedLabel spark ComboBox

此函數bellow返回String以在項呈示器中顯示。

public function itemToLabel(item:Object):String

由於selectedLabel屬性在spark.components.ComboBox已經過時,我添加了這個函數:

public function get selectedLabel():String 
    {
        var item:Object = selectedItem;
        return itemToLabel(item);
    }

但我被阻止public function set selectedLabel(label:String):void

是否有人知道函數labelToItem或另一個解決方案來設置我的組合框selectedLabel

不是最高效的解決方案,但如果你沒有一噸的dataProvider項目的那么這應該是正常的:

public function setSelectedLabel(cb:ComboBox, label:String):void
{
    for each(var item:Object in cb.dataProvider)
    {
        if(item[cb.labelField] == label)
        {
            cb.selectedItem = item;
            return;
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM