小小菜鸟的web菜园子

web开发学习。好记性不如烂笔头。每天进步一点点!

导航

设置ComboBox控件的下拉栏的宽度.

ComboBox控件的dropdownWidth属性.
示例:

代码:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/07/02/setting-the-width-of-the-dropdown-menu-on-a-combobox-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="top"
        backgroundColor
="white">

    
<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:Object label="Seven" />
        
<mx:Object label="Eight" />
        
<mx:Object label="Nine" />
        
<mx:Object label="Ten" />
    
</mx:Array>

    
<mx:ComboBox id="comboBox"
            dataProvider
="{arr}"
            dropdownWidth
="200" />

</mx:Application>

也可以通过AS来实现.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/07/02/setting-the-width-of-the-dropdown-menu-on-a-combobox-control-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="top"
        backgroundColor
="white"
        initialize
="init();">

    
<mx:Script>
        
<![CDATA[
            import mx.controls.ComboBox;

            private var arr:Array;
            private var comboBox:ComboBox;

            private function init():void {
                arr = [];
                arr.push({label:"One"});
                arr.push({label:"Two"});
                arr.push({label:"Three"});
                arr.push({label:"Four"});
                arr.push({label:"Five"});
                arr.push({label:"Six"});
                arr.push({label:"Seven"});
                arr.push({label:"Eight"});
                arr.push({label:"Nine"});
                arr.push({label:"Ten"});

                comboBox = new ComboBox();
                comboBox.dataProvider = arr;
                comboBox.dropdownWidth = 200;
                addChild(comboBox);
            }
        
]]>
    
</mx:Script>

</mx:Application>

posted on 2008-07-14 15:15  『小小菜鸟』  阅读(2108)  评论(0编辑  收藏  举报