Changing the width of dropdown area in flex combobox.
- by DineshDu
I have a combobox which gets populated by a remote method. I need to set the dropdownwidth of the combobox to the maximum length of the item in the combobox. I am able to achieve it by the following code. But if the resolution of the screen changes, the result is not similar. Is there any way to find the display width of the text in the dropdown?
private function getGroupData(resultEvent:ResultEvent):void{
viewCbx.dataProvider = resultEvent.result as ArrayCollection;
var comboDp:ArrayCollection = viewCbx.dataProvider as ArrayCollection;
var dropWidth:int = 0;
for each(var obj:Object in comboDp){
if(obj.groupName.length > dropWidth){
dropWidth = obj.groupName.length;
}
}
viewCbx.dropdownWidth = dropWidth*6;
}