Mega Code Archive

 
Categories / Delphi / ADO Database
 

How to add a Row Number in your DBGrid

Title: How to add a Row Number in your DBGrid procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); begin if DataSource1.DataSet.RecNo 0 then begin if Column.Title.Caption = 'No' then DBGrid1.Canvas.TextOut(Rect.Left + 2, Rect.Top, IntToStr(DataSource1.DataSet.RecNo)); end; end;