双击datagrid 在弹出的对话框中点击 [Add New (Ins)]按钮 指定新添加TColumn的FieldName等
双击DBGrid,先把所有字段加进去,再在最前面加一个字段,在DrawColumnCell中写 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;
在弹出的对话框中点击 [Add New (Ins)]按钮
指定新添加TColumn的FieldName等
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;