The following example shows how you can prevent users from changing the value in a Flex ComboBox control by setting the dropdown menu’s selectable property.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/07/10/preventing-users-from-changing-the-combobox-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="top"
backgroundColor="white">
<mx:Script>
<![CDATA[
import mx.events.DropdownEvent;
private function comboBox_open(evt:DropdownEvent):void {
comboBox.dropdown.selectable = checkBox.selected;
}
]]>
</mx:Script>
<mx:Array id="arr">
<mx:Object label="One" />
<mx:Object label="Two" />
<mx:Object label="Three" />
<mx:Object label="Four" />
<mx:Object label="Five" />
<mx:Object label="Six" />
</mx:Array>
<mx:ApplicationControlBar dock="true">
<mx:CheckBox id="checkBox"
label="selectable:"
labelPlacement="left"
selected="false" />
</mx:ApplicationControlBar>
<mx:ComboBox id="comboBox"
prompt="Please select an item"
dataProvider="[One,Two,Three,Four,Five,Six]"
open="comboBox_open(event);" />
</mx:Application>





Hi!
How can I prevent ComboBox from closing when clicking (selecting) its item. Thanks.