在dbgrid中新建一列为第一列,标题为“序号”,我想让该列显示的数据为ADOTable1的行数,即第一行序号为1,第二行序号为2...
请问该如何写?

解决方案 »

  1.   

    http://dev.csdn.net/article/53/53442.shtm
      

  2.   

    可以通过DBGrid1DrawDataCell时间来做
      

  3.   

    procedure Tform1.DBGrid1DrawColumnCell(Sender: TObject;
      const Rect: TRect; DataCol: Integer; Column: TColumn;
      State: TGridDrawState);
    begin
    if Column.Index = 0 then
      with DBGrid1.Canvas do
        begin
          FillRect(Rect);
          TextOut(Rect.Left+2, Rect.Top+2, IntToStr(DBGrid1.DataSource.DataSet.RecNo));
        end;
    end;