zoukankan      html  css  js  c++  java
  • cxGrid显示行号

    定义一个类:

    TMyCxGrid = class(TObject)
        class procedure DrawIndicatorCell( Sender: TcxGridTableView; ACanvas: TcxCanvas;
          AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
      end;
    
    
    class procedure TMyCxGrid.DrawIndicatorCell(Sender: TcxGridTableView; ACanvas: TcxCanvas;
      AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
    var
      FValue: string;
      FBounds: TRect;
      //method 2
      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, TcxAlignmentVert.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, TcxAlignmentVert.vaCenter,
        False, False, IntToStr(AIndicatorViewInfo.GridRecord.Index + 1),
        AFont, AFontTextColor, AColor);
      ADone := True;
    
    end;

    然后调用即可:

    tvList.OptionsView.Indicator:=True;
    tvList.OptionsView.IndicatorWidth:=30;
    tvList.OnCustomDrawIndicatorCell:= TMyCxGrid.DrawIndicatorCell;


    测试GridMode显示有问题。

  • 相关阅读:
    php composer 相关及版本约束等小技巧
    Jquery 获取表单值如input,select等方法
    Apache benchmark 压力测试工具
    Linux中的随机数文件 /dev/random /dev/urandom
    redis持久化
    Python---装饰器
    高仿拉手网底部菜单实现FragmentActivity+Fragment+RadioGroup
    python实现二叉树和它的七种遍历
    Spring AOP应用实例demo
    二维数组的列排序
  • 原文地址:https://www.cnblogs.com/GarfieldTom/p/3238477.html
Copyright © 2011-2022 走看看