var i : integer; begin i:=0; AdoQuery1.First; While not eof(AdoQuery) do begin AdoQuery1.Edit; AdoQuery1.FieldByName('字段').AsString=inttostr(i); AdoQuery1.Post; i:=i+1; end;
procedure TFrmLog.DBGridDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumnEh; State: TGridDrawState); begin with DBGrid.DataSource.DataSet do begin if DataCol = 0 then//第一列 DBGrid.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, IntToStr(RecNo)); end; end; 有一个问题,就是增加一个空列的时候显示的都是1,我也一直没有解决掉,你要是解决了也告诉我一声:liuqifeiyu2163.com
var i : integer; begin i:=0; AdoQuery1.First; While not eof(AdoQuery) do begin AdoQuery1.Edit; AdoQuery1.FieldByName('字段').AsString=inttostr(i); AdoQuery1.Post; i:=i+1; end;
http://community.csdn.net/Expert/topic/3081/3081253.xml?temp=.283581procedure TFrmLog.DBGridDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumnEh; State: TGridDrawState); begin with DBGrid.DataSource.DataSet do begin if DataCol = 0 then//第一列 DBGrid.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, IntToStr(RecNo)); end; end; 这个是DBGrid的,用到DBGridEH也一样
然后在ADOQuery的OnAfterScroll事件中加入如下一行:
ADOQuery1.Edit;
ADOQuery1.FieldByName('ID').AsInteger := ADOQuery1.RecNo;然后再在OnCalcFields事件中加入下行:
ADOQuery1.FieldByName('ID').AsInteger := ADOQuery1.RecNo;再在DBGrid中加入ID字段显示即可
i : integer;
begin
i:=0;
AdoQuery1.First;
While not eof(AdoQuery) do
begin
AdoQuery1.Edit;
AdoQuery1.FieldByName('字段').AsString=inttostr(i);
AdoQuery1.Post;
i:=i+1;
end;
DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
begin
with DBGrid.DataSource.DataSet do
begin
if DataCol = 0 then//第一列
DBGrid.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, IntToStr(RecNo));
end;
end; 有一个问题,就是增加一个空列的时候显示的都是1,我也一直没有解决掉,你要是解决了也告诉我一声:liuqifeiyu2163.com
i : integer;
begin
i:=0;
AdoQuery1.First;
While not eof(AdoQuery) do
begin
AdoQuery1.Edit;
AdoQuery1.FieldByName('字段').AsString=inttostr(i);
AdoQuery1.Post;
i:=i+1;
end;
DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
begin
with DBGrid.DataSource.DataSet do
begin
if DataCol = 0 then//第一列
DBGrid.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, IntToStr(RecNo));
end;
end;
这个是DBGrid的,用到DBGridEH也一样