带有序号dbgrid固定在左边的控件怎么做啊,
要写成控件,不能在应用程序中在加什么代码?

解决方案 »

  1.   

    1、不知你用的是什么数据库,可以在数据库里用存储过程先给记录编号
    2、用dbgrideh控件试试
    3、写代码,用DrawColumnCell的方法画记录号
      

  2.   

    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;
      

  3.   

    select identity(int,1,1) as '列',列1,列2,列n  into #t from tb_Text Query.sql.text := 'select * from #t'