加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex中ComboBox和datagrid的使用

发布时间:2020-12-15 03:57:53 所属栏目:百科 来源:网络整理
导读:所谓ComboBox就是下拉菜单了 1 2 3 4 (在博客里搞出这东西也不容易啊,代码在下面附上) 先给出一段代码: ?xml version="1.0" encoding="utf-8"? mx:Application xmlns:mx=" [url]http://www.adobe.com/2006/mxml[/url]" layout="absolute" mx:Script ![CDATA[
所谓ComboBox就是下拉菜单了 (在博客里搞出这东西也不容易啊,代码在下面附上)
先给出一段代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=" [url]http://www.adobe.com/2006/mxml[/url]" layout="absolute">
<mx:Script>
<![CDATA[
[Bindable]
public var cards: Array = [ {label:"xhinker1",data:"1.jpg"},
{label:"xhinker2",data:"2.jpg"},{label:"xhinker3",data:"3.jpg"} ];


[Bindable]
public var selectedItem1:Object;
[Bindable]
public var selectedItem2:Object;
]]>
</mx:Script>
<mx:ComboBox x="10" y="10" dataProvider="{cards}" width="150"
close="selectedItem2=ComboBox(event.target).selectedItem">
</mx:ComboBox>
<mx:HBox x="168" y="10" width="368">
<mx:Label text="You selected: {selectedItem2.label}"/>
<mx:Label text="Data: {selectedItem2.data}" width="168"/>
</mx:HBox>
</mx:Application>
不要害怕,重要的地方都用黑体标出来了。[bindable]是捆绑标记,这样数据就可以与部件进行动态交换数据。之后就是combobox里选项的内容了, Array是属性声明,label是外面看到的选项,data就是真正的数据内容。上面例子中数据是图片的地址,图片放在bin文件下。第二段黑体就是真正的combobox了。下面一段可有可无,用来检验的。注意红色的部分这些是需要自己声明的。
下面讲DataGrid,首先把代码全部给出来:
<mx:XMLList id="employees">
<employee>
<name>xhinker1</name>
<phone>555-219-2270</phone>
<email> ccoenraets@fictitious.com</email>
<active>true</active>
</employee>
<employee>
<name>xhinker2</name>
<phone>555-219-2012</phone>
<email> jwall@fictitious.com</email>
<active>true</active>
</employee>
<employee>
<name>xhinker3</name>
<phone>555-219-2012</phone>
<email> maurice@fictitious.com</email>
<active>false</active>
</employee>
<employee>
<name>xhinker4</name>
<phone>555-219-2000</phone>
<email> mjones@fictitious.com</email>
<active>true</active>
</employee>
</mx:XMLList>
这里是用xml存储数据将来会在表格中显示出来.
<mx:DataGrid id="dg" rowCount="4" dataProvider="{employees}" enabled="true">
<mx:columns>
<mx:DataGridColumn dataField="name" headerText="Name"/>
<mx:DataGridColumn dataField="phone" headerText="Phone"/>
<mx:DataGridColumn dataField="email" headerText="Email"/>
</mx:columns>
</mx:DataGrid>
这一段就把数据显示出来了也不是太难了,adobe flex不提供傻瓜式输入,我们就得辛苦一点自己输入了。
?
下拉菜单的博客代码<SELECT size=1 name=select> <OPTION selected>1</OPTION> <OPTION>2</OPTION> <OPTION>3</OPTION> <OPTION>4</OPTION></SELECT>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读