`

datagrid中修改背景颜色式样

 
阅读更多
以下转载官方文档
//http://www.adobe.com/devnet/flash/quickstart/datagrid_pt3.html
啥都不多说了,老外的文档注释说得已经很详细了。直接上代码
package { 
// Import the required component classes. 
 import fl.controls.listClasses.CellRenderer;
 import fl.controls.listClasses.ICellRenderer; 
 
 /** * This class sets the upSkin style based on the current item's index in a list. 
 * Make sure the class is marked "public" and in the case of our custom cell renderer, * extends the CellRenderer class and implements the ICellRenderer interface.  */ 
 
 public class AlternatingRowColors extends CellRenderer implements ICellRenderer {
      /** * Constructor. */ 
  		public function AlternatingRowColors():void { 
  			super();
   		} 
   		
       /** * This method returns the style definition object from the CellRenderer class. */ 
  		public static function getStyleDefinition():Object 
  		{ 
  			return CellRenderer.getStyleDefinition();
   		} 
  
      /** * This method overrides the inherited drawBackground() method and sets    the renderer's * upSkin style based on the row's current index. For example, if the row index is an * odd number,the upSkin style is set to the CellRenderer_upSkinDarkGray linkage in the * library. If the row index is an even number, the upSkin style is set to the * CellRenderer_upSkinGray 
      linkage in the library. 
      */ 
   		override protected function drawBackground():void { 
   			if (_listData.index % 2 == 0) { 
   				setStyle("upSkin", CellRenderer_upSkinGray);
    		} 
    		else{ 
    			setStyle("upSkin", CellRenderer_upSkinDarkGray);
    		}
    		 super.drawBackground(); 
    		 } 
    	} 
 }
分享到:
评论

相关推荐

    wpf中datagrid动态设置单元格背景

    当我们需要根据数据的某些条件动态改变`DataGrid`中单元格的背景颜色时,就需要对控件进行一些定制化操作。以下将详细讲解如何实现这个功能。 首先,我们需要理解`DataGrid`的基本结构。`DataGrid`的每一行由多个`...

    WPF DataGrid 行的背景色根据行中某一字段的值来显示

    WPF的DataGrid展示数据源数据时,需要根据某行中某一字段值,来显示背景颜色。这里简单做了一个int类型的值,为0的时候为橙色,为1的时候为草绿色....也可以在数据源中添加Color列,并直接存放Color的16进制值,并...

    wpf datagrid 单元格颜色 根据条件改变颜色 例子

    本篇文章将详细讲解如何在WPF中实现DataGrid单元格颜色根据条件改变。 首先,我们需要了解WPF DataGrid的基础知识。DataGrid通常通过绑定到数据源(如ObservableCollection或ICollectionView)来显示数据。每个...

    设置datagrid行背景色示例

    在本示例中,我们关注的是如何设置 `Datagrid` 的行背景色,以增强视觉效果,帮助用户更好地理解和区分不同的数据。 首先,让我们了解 `Datagrid` 的基本概念。`Datagrid` 是一个控件,通常由多个行和列组成,每一...

    datagrid行的背景色

    在实际应用中,我们经常需要根据特定条件或者需求自定义Datagrid的行背景色,以增强视觉效果,或者突出显示特定行的信息。本文将深入探讨如何在Flex中实现对datagrid行背景色的自定义。 首先,了解Flex Datagrid的...

    DataGrid的单元格背景和文字颜色

    在模板内,你可以直接设置TextBlock或其他元素的Foreground和Background属性,以改变文字和背景颜色。 ```xml <DataGrid> <DataGrid.Columns> </DataGrid.Columns> </DataGrid> ``` 2. **使用...

    flex DataGrid改变指定行的背景颜色

    在某些情况下,我们可能需要根据特定条件改变DataGrid中的某一行或几行的背景颜色,以突出显示或者区分不同的数据状态。本篇文章将详细探讨如何在Flex中实现这一功能。 首先,我们需要理解DataGrid的基本结构。...

    Flex DataGrid 改变某一行的背景颜色

    在实际应用中,我们经常需要根据特定条件改变DataGrid中某一行的背景颜色,以突出显示特定数据或提供视觉反馈。本文将详细讲解如何在Flex中实现这一功能。 首先,我们要了解Flex DataGrid的基本结构。DataGrid由一...

    C#实现改变DataGrid某一行和单元格颜色的方法

    例如,将第2行的高度设为50,背景颜色设为蓝色,如果id值为DBNull,则将背景颜色设为绿色。 ```csharp for (int i = 0; i < this.dataGrid1.Items.Count; i++) { DataRowView drv = dataGrid1.Items[i] as ...

    wpf datagrid 单元格颜色 根据datatable动态显示datagrid内容

    本主题将深入探讨如何根据DataTable中的数据动态显示DataGrid的内容,并且根据特定条件改变单元格的颜色。 首先,我们需要了解DataGrid的基本用法。DataGrid控件允许我们将数据绑定到各种数据源,如...

    dataGrid根据条件行显示不同的颜色

    在本示例中,我们关注的是如何根据特定条件为DataGrid的行设置不同的颜色,这有助于提升数据的可读性和视觉效果。以下是关于这个主题的详细知识点: 1. **DataGrid概述**:DataGrid是一种网格布局控件,它能够以...

    DATAGRID改变颜色

    总结来说,改变`DataGrid`中行的颜色涉及理解`DataGrid`的事件机制、样式和数据绑定原理。通过监听适当的事件并根据数据源的值设置行的样式,我们可以实现根据条件改变颜色的需求。无论是Windows Forms还是WPF,都有...

    DataGrid中嵌套DataGrid

    在ASP.NET开发中,DataGrid控件是一种常用的用于展示数据的控件,它允许我们以表格形式呈现数据源中的信息。而"DataGrid中嵌套DataGrid"是一种复杂但非常实用的技术,它允许在一个DataGrid的行或列中内嵌另一个...

    DataGrid中嵌入comBox

    在Windows Presentation Foundation(WPF)开发中,DataGrid控件是一种强大的工具,用于展示和编辑表格数据。在某些场景下,我们可能需要在DataGrid的某一列中嵌入ComboBox控件,以提供用户多选或者下拉选择的功能。...

    flex 中datagrid 动态攺变行颜色

    4. **实时更新颜色**:如果行颜色需要根据用户操作或业务逻辑动态改变,我们可以在事件处理函数中修改数据源中对应的`rowColor`值,然后Datagrid会自动调用ItemRenderer来更新颜色。 以上就是关于在Flex中动态改变...

    DataGrid自定义列标题

    在.NET框架中,WPF(Windows Presentation Foundation)提供了一个强大的数据呈现控件——DataGrid,它用于显示和编辑网格形式的数据。在实际开发中,我们经常需要根据需求对DataGrid的列标题进行自定义,以增强界面...

    FLASH中DataGrid改为交替背景色,一行白色,一行灰色

    在本篇文章中,我们将探讨如何在Flash中对DataGrid组件进行自定义,使其显示交替的行背景颜色(即一行白色,一行灰色)。这种方法类似于Flex框架中的DataGrid样式,并且能够提高用户界面的可读性和美观度。下面将...

    WPF_MVVM中DataGrid列中使用ComBox绑定

    本话题将探讨如何在MVVM架构下,将ComBox控件集成到DataGrid列中,并实现其与数据模型的双向绑定,以实现在选择ComBox项后,数据能够即时更新到绑定的实体中。 首先,我们需要理解DataGrid的基本用法。DataGrid是...

    修改DataGrid表头样式

    在实际应用中,我们往往需要根据设计需求对DataGrid的外观进行定制,包括改变表头的样式。本篇将详细介绍如何修改DataGrid的表头样式,以实现个性化的设计。 首先,我们要理解DataGrid的结构。DataGrid由多个部分...

    NET CF下DataGrid数据行颜色交替

    1. **自定义列渲染**:你可以重写DataGrid的`OnDrawColumnCell`事件,根据当前行的索引判断是否应该改变背景色。例如,对于偶数行设置一种颜色,奇数行设置另一种颜色。 ```csharp private void dataGrid1_...

Global site tag (gtag.js) - Google Analytics