How to get Flex 3 ComboBox width to adjust based on bound dataProvider contents having changed?

折月煮酒 提交于 2019-12-01 13:21:18

You probably just need to call invalidateProperties(), invalidateDisplayList(), invalidateSize(), or some combination of the three (I'm something of a flex newbie myself), to force an update to the component's measurements after changing the data provider or its contents.

myComponentId.invalidateSize();
myComponentId.invalidateDisplayList();
myComponentId.invalidateProperties();

I would add a setter for choices and call validateNow() on the ComboBox at the end of the setter:

public function set choices(value:ArrayCollection):void
{
    _choices = value;

    comboBox.validateNow();
}

I encountered the same problem and neither of these worked for me. I managed to solve this by creating a new event handler

menuComboBox.addEventListener(ResizeEvent.RESIZE, updateListWidth);

The method called in this event simply resizes the dropdown.width property.

private function updateListWidth(event:ResizeEvent):void {
        menuComboBox.dropdown.width = menuComboBox.width;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!