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; 

  • 相关阅读:
    idea 添加不同的模板文件比如 . vm 文件
    Spring ioc及aop思想
    idea配置非maven项目配置及热部署配置
    AES对称式加密及https加密算法中数字证书(非对称加密)
    Solr(搜索引擎)简单介绍(不一定要会用但是要知道)
    回炉重造-基础规则之初识static关键字
    回炉重造-基础规则之初识IO流
    回炉重造-基础规则之类和对象
    回炉重造-基础规则之行为方法
    回炉重造-基础规则之Java的数组
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/2940638.html
Copyright © 2011-2022 走看看