Flex中如何通过headerStyleName和color样式设置DataGrid头部列文本颜色的例子

By Minidxer | June 26, 2009

接下来的例子演示了Flex中如何通过headerStyleName和color样式,设置DataGrid头部列文本颜色。

让我们先来看一下Demo可以点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application name="DataGrid_headerStyleName_color_test"
  3.         xmlns:mx="http://www.adobe.com/2006/mxml"
  4.         layout="vertical"
  5.         verticalAlign="middle"
  6.         backgroundColor="white">
  7.  
  8.     <mx:Style>
  9.         .myHeaderStyles {
  10.             color: red;
  11.             fontWeight: bold;
  12.         }
  13.     </mx:Style>
  14.  
  15.     <mx:Array id="arrDP">
  16.         <mx:Object c="1" c1="One" c2="Two" c3="Three" />
  17.         <mx:Object c="2" c1="One" c2="Two" c3="Three" />
  18.         <mx:Object c="3" c1="One" c2="Two" c3="Three" />
  19.         <mx:Object c="4" c1="One" c2="Two" c3="Three" />
  20.         <mx:Object c="5" c1="One" c2="Two" c3="Three" />
  21.         <mx:Object c="6" c1="One" c2="Two" c3="Three" />
  22.         <mx:Object c="7" c1="One" c2="Two" c3="Three" />
  23.         <mx:Object c="8" c1="One" c2="Two" c3="Three" />
  24.         <mx:Object c="9" c1="One" c2="Two" c3="Three" />
  25.         <mx:Object c="10" c1="One" c2="Two" c3="Three" />
  26.         <mx:Object c="11" c1="One" c2="Two" c3="Three" />
  27.     </mx:Array>
  28.  
  29.     <mx:DataGrid id="dataGrid"
  30.             dataProvider="{arrDP}"
  31.             headerStyleName="myHeaderStyles" />
  32.  
  33. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: DataGrid | No Comments » | 1,237 views Tags: , ,

Search Posts