RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TDataSet.RecNo Property

Indicates the active record in the dataset.

Pascal
property RecNo: Integer;
C++
__property int RecNo;

As implemented in TDataSet, the value of RecNo is always -1. Ordinarily an application does not access RecNo at the TDataSet level. Instead a re-implemented RecNo property in a descendant class such as TTable TClientDataSet is accessed. RecNo provides a fallback property for derived datasets that do not support record numbers.  

Delphi Examples: 

 

{
This example adds an entry to a memo with a message
when an AfterEdit event occurs and when a BeforeEdit event
occurs.  Click on Run SQL to populate the DBGrid.  Then
select a cell to edit and click the Edit current cell
button, or just start editing the cell to invoke the
BeforeEdit and AfterEdit events.
} 
procedure TForm1.ClientDataSet1AfterEdit(DataSet: TDataSet);
begin
   Memo2.Lines.Add('After editing record' + IntToStr(DataSet.RecNo));
end;

procedure TForm1.ClientDataSet1BeforeEdit(DataSet: TDataSet);
begin
   Memo2.Lines.Add('Before editing record' + IntToStr(DataSet.RecNo));
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  ClientDataSet1.Edit;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!