Displaying icons in a Flex ComboBox control

简介:

making the ComboBox control display icons also should be pretty trivial. Well, after about 2 minutes of analyzing the documentation, it turns out it is pretty simple. The trick was to set the iconField property on the ComboBox instance’s dropdownproperty, which is a reference to the combo box’s internal List control

<? xml version="1.0" encoding="utf-8" ?>
<!--  http://blog.flexexamples.com/2007/08/18/displaying-icons-in-a-flex-combobox-control/  -->
< mx:Application  xmlns:mx ="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="middle"
        backgroundColor
="white" >

    
< mx:Script >
        
<![CDATA[
            import mx.events.FlexEvent;

            [Bindable]
            [Embed(source="assets/bulletCheck.png")]
            public var BulletCheck:Class;

            [Bindable]
            [Embed(source="assets/bulletWarning.png")]
            public var BulletWarning:Class;

            [Bindable]
            [Embed(source="assets/bulletCritical.png")]
            public var BulletCritical:Class;

            private function init():void {
                comboBox.dropdown.iconField = "icon";
            }
        
]]>
    
</ mx:Script >

    
< mx:ComboBox  id ="comboBox"
            rowCount
="4"
            width
="200"
            themeColor
="haloSilver"
            textIndent
="5"
            selectedIndex
="-1"
            prompt
="Please select an item"
            creationComplete
="init()" >
        
< mx:dataProvider >
            
< mx:Array >
                
< mx:Object  label ="Item 1"  icon ="BulletWarning"   />
                
< mx:Object  label ="Item 2"  icon ="BulletCritical"   />
                
< mx:Object  label ="Item 3"  icon ="BulletCritical"   />
                
< mx:Object  label ="Item 4"  icon ="BulletCheck"   />
                
< mx:Object  label ="Item 5"  icon ="BulletWarning"   />
                
< mx:Object  label ="Item 6"  icon ="BulletCheck"   />
                
< mx:Object  label ="Item 7"  icon ="BulletCheck"   />
                
< mx:Object  label ="Item 8"  icon ="BulletCritical"   />
            
</ mx:Array >
        
</ mx:dataProvider >
    
</ mx:ComboBox >

</ mx:Application >

    本文转自 OldHawk  博客园博客,原文链接:http://www.cnblogs.com/taobataoma/archive/2008/01/11/1035780.html ,如需转载请自行联系原作者





相关文章
|
7月前
|
容器
SAP UI5 Form 表单的 Responsive Grid Layout 布局中的 breakpoint
SAP UI5 Form 表单的 Responsive Grid Layout 布局中的 breakpoint
25 0
SAP Engagement Center的ShellCarousel控件control
SAP Engagement Center的ShellCarousel控件control
81 0
SAP Engagement Center的ShellCarousel控件control
different styles of button in footer area
Created by Jerry Wang, last modified on Sep 02, 2015
different styles of button in footer area
|
开发框架 前端开发 .NET
|
XML 存储 数据格式