当前位置: 移动技术网 > IT编程>开发语言>Delphi > 如何让tcxGrid左边显示序号

如何让tcxGrid左边显示序号

2020年03月17日  | 移动技术网IT编程  | 我要评论
第一步:

设置cxgrid的属性, optionsview.indicator = true

第二步:

写oncustomdrawindicatorcell方法

procedure tform1.cxgrid1dbtableview1customdrawindicatorcell(sender: tcxgridtableview; acanvas: tcxcanvas; aviewinfo: tcxcustomgridindicatoritemviewinfo; var adone: boolean);
var
  fvalue: string;
  fbounds: trect;
begin
  if (aviewinfo is tcxgridindicatorrowitemviewinfo) then
  begin
    fvalue := inttostr(tcxgridindicatorrowitemviewinfo(aviewinfo).gridrecord.index + 1);
    fbounds := aviewinfo.bounds;
    acanvas.fillrect(fbounds);
    acanvas.drawcomplexframe(fbounds, clbtnhighlight, clbtnshadow, [bbottom, bleft, bright], 1);
    inflaterect(fbounds, -1, -1);
    acanvas.font.color := clblack;
    acanvas.brush.style := bsclear;
    acanvas.drawtext(fvalue, fbounds, cxaligncenter or cxaligntop);
    adone := true;
  end;
end;

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网