如何让tcxGrid左边显示序号
程序员文章站
2022-06-09 17:02:35
第一步: 设置cxgrid的属性, OptionsView.Indicator = True 第二步: 写OnCustomDrawIndicatorCell方法 procedure TForm1.cxGrid1DBTableView1CustomDrawIndicatorCell(Sender: T ......
第一步: 设置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;