windson

如何让tcxGrid左边显示序号

第一步:

设置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;

 

分类:

技术点:

相关文章:

  • 2021-07-16
  • 2021-11-07
  • 2021-08-03
  • 2021-11-08
  • 2021-09-28
  • 2021-07-29
猜你喜欢
  • 2021-12-15
  • 2021-06-28
  • 2021-09-25
  • 2021-12-26
  • 2021-12-01
  • 2021-11-09
  • 2021-08-13
相关资源
相似解决方案