0

我想以编程方式更改火花组合框中突出显示的项目。当带有所选项目的组合框弹出窗口打开时,它在弹出窗口中显示为突出显示的颜色。现在打开弹出窗口后,我通过设置 selectedIndex 和 selectedItem 属性以编程方式更改了所选项目。文本输入随着给定的所选项目而更改,但突出显示的颜色仍然显示之前的值。如何将该突出显示的项目更改为选定项目。任何人都可以为此提供解决方案。

public class AutoSortComboBox extends ComboBox{



    public function AutoSortComboBox ():void    {   
                super();   
    }
    protected function sortDataProvider(descending:Boolean):void{

                var arrColl:ArrayCollection = this.dataProvider as ArrayCollection;
                var selectedItem:Object = this.selectedItem as Object;
                this.selectedIndex = -1;
                var dataSortField:SortField = new SortField();
                dataSortField.name = "label";
                dataSortField.numeric = false;
                dataSortField.descending = descending;
                /* Create the Sort object and add the SortField object created earlier to the array of fields to sort on. */
                var numericDataSort:Sort = new Sort();
                numericDataSort.fields = [dataSortField];
                arrColl.sort = numericDataSort;
                arrColl.refresh();
                if(selectedItem != null)
                {
                    for(var i:int=0;i<arrColl.length;i++)
                    {
                        if(selectedItem.label == arrColl[i].label)
                            this.selectedIndex = i;
                    }
                    this.selectedItem = selectedItem;
                }
     }
  }
4

1 回答 1

0

这两个之一应该工作:

FocusManager.SetFocus(DisplayObject)

或者

 Combobox.selectedItem = ItemFromCombobox
于 2012-12-04T22:53:08.960 回答