zoukankan      html  css  js  c++  java
  • cxgrid动态显示行号

    uses cxLookAndFeelPainters;

      

    type

      TMyCxGrid = class(TObject)
        class procedure DrawIndicatorCell(
          Sender: TcxGridTableView; ACanvas: TcxCanvas;
          AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
      end;

    { TMyCxGrid }

    class procedure TMyCxGrid.DrawIndicatorCell(Sender: TcxGridTableView;
      ACanvas: TcxCanvas; AViewInfo: TcxCustomGridIndicatorItemViewInfo;
      var ADone: Boolean);
    var
      AIndicatorViewInfo: TcxGridIndicatorRowItemViewInfo;
      ATextRect: TRect;
      AFont: TFont;
      AFontTextColor, AColor: TColor;
    begin
      AFont := ACanvas.Font;
      AColor := clBtnFace;
      AFontTextColor := clWindowText;
      if (AViewInfo is TcxGridIndicatorHeaderItemViewInfo) then
      begin
        ATextRect := AViewInfo.Bounds;
        InflateRect(ATextRect, -1, -1);

        Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.Bounds,
          ATextRect, [], cxBordersAll, cxbsNormal, taCenter, vaCenter,
          False, False, 'NO',AFont, AFontTextColor, AColor);
        ADone := True;
      end;
      if not (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
        Exit;
      ATextRect := AViewInfo.ContentBounds;
      AIndicatorViewInfo := AViewInfo as TcxGridIndicatorRowItemViewInfo;
      InflateRect(ATextRect, -1, -1);

      if AIndicatorViewInfo.GridRecord.Selected then
        AFont.Style := ACanvas.Font.Style + [fsBold]
      else
        AFont.Style := ACanvas.Font.Style - [fsBold];

      Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds,
        ATextRect, [], [bBottom, bLeft, bRight], cxbsNormal, taCenter, vaCenter,
        False, False, IntToStr(AIndicatorViewInfo.GridRecord.Index + 1),
        AFont, AFontTextColor, AColor);
      ADone := True;
    //  ASender.LookAndFeelPainter.DrawIndicatorImage(ACanvas, ATextRect,
    //    AIndicatorViewInfo.IndicatorKind);

    end;

    procedure ShowLineNo(c: TcxGridDBTableView);
    begin
      c.OptionsView.Indicator := True;
      c.OptionsView.IndicatorWidth := 40;
      c.OnCustomDrawIndicatorCell := TMyCxGrid.DrawIndicatorCell;
    end; 

     
     
     
    好文要顶 关注我 收藏该文 
  • 相关阅读:
    关于在MyEclipse中页面中文乱码的问题
    如何用Navicat for MySQL 将mysql中的数据库导出,导入。
    淘宝链接池的配置
    c3p0配置
    人生规划
    spring问题: Unable to validate using XSD: Your JAXP provider
    List数组和Set集合
    Tomcat6内存不足问题及解决方法
    清华校长送给毕业生的五句话
    个人图文理解类的封装
  • 原文地址:https://www.cnblogs.com/westsoft/p/5962630.html
Copyright © 2011-2022 走看看