关于TDBGRID显示行号的问题???

解决方案 »

  1.   

    这个问题DBGRID很难解决的,到现在还没有好的方法!
      

  2.   

    DBGRID本身无行号,可以用其它方法.SQL(要数据库支持)或是计算字段等.
      

  3.   

    增加一个计算字段,放到第1列
    在DBGrid的OnDrawColumnCell事件中: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;
      

  4.   

    增加一个计算字段,放到第1列
    在oncalculate事件里写
    adoquery1newfield.value:=adoquery1.recNo;
      

  5.   

    解释一下DBGrid的OnDrawColumnCell是什么事件啊?
      

  6.   

    增加一个计算字段,放到第1列
    procedure TForm4.ADOQuery1IDGetText(Sender: TField; var Text: String;
      DisplayText: Boolean);
    begin
    if adoquery1.RecNo>0 then
    Text:=IntToStr(adoquery1.RecNo);
    end;