论坛首页 综合技术论坛

Delphi7中cxGrid控件自动编号

浏览 1947 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2011-08-05  

在cxGrid的GridView属性设置事件onGridCustomDrawIndicatorCell,事件关键代码如下:

 

procedure TfrmHidden_Trouble.GridCustomDrawIndicatorCell(
  Sender: TcxGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
var
  AIndicatorViewInfo: TcxGridIndicatorRowItemViewInfo;
  ATextRect: TRect;
  aCV:TcxCanvas;
begin
  inherited;
  //======引用单元  cxLookAndFeelPainters
  if not (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
    Exit;
  aCV:=ACanvas ;
  ATextRect := AViewInfo.ContentBounds;
  AIndicatorViewInfo := AViewInfo as TcxGridIndicatorRowItemViewInfo;
  InflateRect(ATextRect, -2, -1);
  Sender.LookAndFeelPainter.DrawHeader(ACanvas, AViewInfo.ContentBounds,
    ATextRect, [], cxBordersAll, cxbsNormal, taCenter, TcxAlignmentVert(vaCenter),
    False, False, IntToStr(AIndicatorViewInfo.GridRecord.Index + 1),
  acv.Font,acv.font.Color,acv.Brush.color );
  ADone := True;
end;

 

论坛首页 综合技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics