devxlogo

How to display “Record x of y”

How to display “Record x of y”

Question:
I am writing a database app in Delphi that is a Customer/Order Management System, and need to display a ‘3 of 7’ type info in the status bar. How can I get the position and number of records?

Answer:
TTable has two properties for displaying the current record and totalrecords, respectively. They are:

RecNo and RecordCount

Your best bet is to place the code that would display these values inthe OnDataChange event of your DataSource component as follows:

procedure TIFMain.DataSource1DataChange(Sender: TObject; Field: TField);begin  Panel1.Caption := IntToStr(Table1.RecNo) + ‘ of ‘ +                     IntToStr(Table1.RecordCount);end;
because OnDataChange occurs every time something happens to the underlying dataset, like scrolling to a new record.

See also  lenso.ai - an AI reverse image search platform
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist