下拉列表控件实例 ComboBoxControl

下拉列表控件实例

书:151页

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Declarations>
        <!-- 将非可视元素(例如服务、值对象)放在此处 -->
    </fx:Declarations>
    <!-- 下拉列表控件实例 -->
    <fx:Script>
        <![CDATA[
            import spark.events.DropDownEvent;
            [Bindable]public var selectedItem:Object;
            
            protected function combobox1_closeHandler(event:DropDownEvent):void
            {
                // TODO Auto-generated method stub
                
            }
            
        ]]>
    </fx:Script>
    
    <mx:Panel title="下拉列表控件实例" height="75%" width="75%" paddingTop="10" paddingLeft="10">
        <mx:ComboBox close="selectedItem=ComboBox(event.target).selectedItem" editable="true">
            <mx:dataProvider>
                <mx:ArrayCollection>
                    <mx:source>
                        <fx:Object label="青海" data="西宁"/>
                        <fx:Object label="甘肃" data="兰州"/>
                        <fx:Object label="宁夏" data="银川"/>
                        <fx:Object label="陕西" data="西安"/>
                        <fx:Object label="新疆" data="乌鲁木齐"/>
                        <fx:Object label="西藏" data="拉萨"/>
                    </mx:source>
                </mx:ArrayCollection>
            </mx:dataProvider>
        </mx:ComboBox>
        <mx:Label id="lb1" text="您选择了:{selectedItem.label},省会:{selectedItem.data}" />
    </mx:Panel>
</s:Application>

 

posted @ 2019-04-10 14:51  阴翳公子  阅读(322)  评论(0编辑  收藏  举报