zoukankan      html  css  js  c++  java
  • DataGrid

    flash cs3中使用DataGrid组件时, 要改变单元格里的字体大小颜色真是麻烦!
    以下是方法:

    var list:DataGrid = new DataGrid();
    //其他的数据,宽高什么的等属性自己设去吧;

    ////////TextFormat////////
    var tf1:TextFormat = new TextFormat();
    tf1.size = 12;
    tf1.color = 0x000000;
    //其他的属性自己调;

    var tf2:TextFormat = new TextFormat();
    tf2.size = 13;
    tf2.color = 0xff0000;
    tf2.bold = true;
    //其他的属性自己调;
    ////////TextFormat////////

    //下面是应用:
    list.setRendererStyle("textFormat", tf1);//这是设置表头上的单元格文字格式;
    list.setStyle("headerTextFormat", tf2);//这是设置表内单元格上的文字样式;

    以前是表格内所有单元格沿用一种样式, 但有时候希望某一列的样式要不一样. 比方说我要第一列的内容居中,其他的还是上面那种样式呢?
    那就看下面:

    新建一个类:

    package {
        import fl.controls.listClasses.CellRenderer;
        import fl.controls.listClasses.ICellRenderer;
        import flash.text.TextFormat;
        
        public class CellStyle1 extends CellRenderer implements ICellRenderer {

            public function CellStyle1():void {
                super();
            }

            override protected  function drawBackground():void {
                var format:TextFormat=new TextFormat  ;

                format.color=0x000000;
                format.size=12;
                format.align = "center";
                //其他属性自己设;
                setStyle("textFormat",format);
                super.drawBackground();
            }
        }
    }

    应用:

    //将第一列所有单元格的样式设置为CellStyle1里的format所具有的样式;单元格表头不在范围内;
    list.getColumnAt(0).cellRenderer = CellStyle1;

    //当然也可以一次性设置同一种样式;
    list.setStyle("cellRenderer",CellStyle1);
    (如果CellStyle1里的format的样式效果和tf1相同的话,那么上面效果等同于:
    list.setRendererStyle("textFormat", tf1);//这是设置表头上的单元格文字格式;

    如果每列都要不同的效果可能就要多个CellStye1类吧!
  • 相关阅读:
    ssh:connect to host xxx port 22: Connection refused---------you don't have permission to acccess the requested location--------remote host identification has changed
    YOLOV3算法笔记
    jQuery元素查找方法
    jquery获取元素方式
    jQuery常用事件
    Jquery常用方法
    JavaScript数组操作
    jQuery中.bind() .live() .delegate() .on()的区别
    CSS初始化代码
    jQuery判断浏览器
  • 原文地址:https://www.cnblogs.com/xcai/p/2647907.html
Copyright © 2011-2022 走看看