因为我一般都是在另一个EDITFORM中增改值的,所以没怎么注意……看看…… [解决办法] procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin with TStringGrid(DBGrid1) do begin if row = MouseCoord(Rect.Left+1, Rect.Top+1).Y then begin Canvas.Brush.Color := clblue; Canvas.Font.Color := clWhite; end; end; TDBGrid(Sender).DefaultDrawColumnCell(Rect,DataCol,Column,State);
如上图添加一列标识栏位 procedure TForm1.DBGridEh1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumnEh; State: TGridDrawState); begin if Column.Index = 0 then with DBGrideh1.Canvas do begin FillRect(Rect); TextOut(Rect.Left+2, Rect.Top+2, IntToStr(DBGrideh1.DataSource.DataSet.RecNo)); end; 效果如下图