打印

[FLEX] 能否设计这样的combox?

1:设置combox可以编辑
   2:当combox被页面载入后,不让其有默认的选择,而使默认选择为空,目的是让用户点击下拉框选择相应选项后,才在可编辑的combox框中显示数据。
  我的实现办法是保持在 <mx:ArrayCollection>的第一项目为空,如下代码所示,显然,让第一项为空这种折衷的办法感觉不好,能否有其它的办法?
  <mx:ComboBox x="427" y="247" id="cbo" editable="true" fontSize="13" >
            <mx:ArrayCollection>
                 <mx:Object label="" data="aa" />            
                 <mx:Object label="第一组雇员" data="aa" />
                 <mx:Object label="第二组雇员" data="bb" />
                 <mx:Object label="第一组雇员1" data="cc" />               
            </mx:ArrayCollection>
     </mx:ComboBox>
设置ComboBox的selectedIndex="-1"就行了。
感谢指教,
  设置ComboBox的selectedIndex="-1"的确能实行我上面的要求,但我发现设置为-1后,存在一个问题:无法通过AS脚本对ComboBox的当前selectedIndex="-1"这个默认选项进行赋值?
比如下面的代码
   如何让下面的combox的显示框中显示为‘hello',该如何通过AS赋值?
    <cmboBox x="427" y="247"  id="cbo" editable="true" selectedIndex="-1" fontSize="13" >
            <mx:ArrayCollection>                        
                 <mx:Object label="第一组雇员" data="aa" />
                 <mx:Object label="第二组雇员" data="bb" />
                 <mx:Object label="第一组雇员1" data="cc" />               
            </mx:ArrayCollection>
     </mx:ComboBox>
不知道该如何解决?
ComboBox.prompt , 设置 ComboBox 默认或者 selectedIndex 为 -1 时显示的值, 相当于一个提示, 不会被计入 value 或者 selectedItem 中

TOP

还在为头像烦恼?还在为不能关注好友动态烦忧?快来蓝色理想家园吧!