TcxGrid最左边显示序号

步骤

1.设置cxgrid的属性, OptionsView.Indicator = True

2.OnCustomDrawIndicatorCell事件
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;

猜你喜欢

转载自blog.csdn.net/baidu_37534986/article/details/83857423