cxgrid动态显示行号

Posted 我的学习笔记

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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; 

 
 
 
好文要顶 关注我 收藏该文 

以上是关于cxgrid动态显示行号的主要内容,如果未能解决你的问题,请参考以下文章

Delphi cxGrid加行号

.NET c#中dataGrid显示行号

将行动态添加到TableLayoutPanel会在不同的行号(位置)上显示

_CRTDBG_MAP_ALLOC 不显示文件名和行号

linuxvim显示行号,linux vim设置行号

如何让VIM显示行号