增加一个计算字段,放到第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;
增加一个计算字段,放到第1列 procedure TForm4.ADOQuery1IDGetText(Sender: TField; var Text: String; DisplayText: Boolean); begin if adoquery1.RecNo>0 then Text:=IntToStr(adoquery1.RecNo); end;
在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;
在oncalculate事件里写
adoquery1newfield.value:=adoquery1.recNo;
procedure TForm4.ADOQuery1IDGetText(Sender: TField; var Text: String;
DisplayText: Boolean);
begin
if adoquery1.RecNo>0 then
Text:=IntToStr(adoquery1.RecNo);
end;