如题

解决方案 »

  1.   

    在TableView的CustomDrawIndicatorCell事件写代码.procedure TForm1.cxGrid1DBTableView1CustomDrawIndicatorCell(
      Sender: TcxGridTableView; ACanvas: TcxCanvas;
      AViewInfo: TcxCustomGridIndicatorItemViewInfo; var ADone: Boolean);
    var
      FValue: string;
      FBounds: TRect;
    begin
      FBounds := AViewInfo.Bounds;
      if (AViewInfo is TcxGridIndicatorRowItemViewInfo) then
      begin
        ACanvas.FillRect(FBounds);
        ACanvas.DrawComplexFrame(FBounds, clBlack, clBlack, [bBottom, bLeft, bRight], 1);
        FValue :=IntToStr(TcxGridIndicatorRowItemViewInfo(AViewInfo).GridRecord.Index+1);
        InflateRect(FBounds, -3, -2); //Platform specific. May not work on Linux.
        ACanvas.Font.Color := clBlack;
        ACanvas.Brush.Style := bsClear;
        ACanvas.DrawText(FValue, FBounds, cxAlignCenter or cxAlignTop);
        ADone := True;
      end;
    end;
      

  2.   

    如果是SQL SERVER的话,可以直接在SQL语句中,用IDENTITY函数(例如IDENTITY(int,1,1)),自动生成一列。
      

  3.   

    to cncharles(旺仔)
    非常感谢,功能已经实现了,但你画的是lfUltraFlat风格的,lfUltraFlat好难看啊,能给个画成lfFlat风格的吗?
      

  4.   

    DrawComplexFame改成
    ACanvas.DrawComplexFrame(FBounds, clBtnHighlight, clBtnShadow, [bBottom, bLeft, bRight], 1);
    InflateRect改成
    InflateRect(FBounds, -1, -1)