Solved

the last record that is displayed in the dbgrid?

Posted on 1998-07-01
6
296 Views
Last Modified: 2010-04-04
I want to get the last(or the nth) record that is
displayed in the dbgrid,how can I get it?
0
Comment
Question by:yd
6 Comments
 
LVL 1

Expert Comment

by:michaue
ID: 1356895
If you are using Paradox tables set the RecNo property of the TTable component to move to the record (9th or whatever)

Or you can look at the MoveBy method of TDataset
0
 
LVL 1

Expert Comment

by:michaue
ID: 1356896
Or if it's truely the very last record use the TDataSet.Last method !!!
0
 
LVL 3

Expert Comment

by:vladika
ID: 1356897
Try to create your own component

type
  TMyDBGrid = class(TDBGrid)
  public
    procedure ScrollToFirstVisible;
    procedure ScrollToLastVisible;
    procedure ScrollToNVisibleRow(N: Integer);
  end;

procedure TMyDBGrid.ScrollToFirstVisible;
begin
  with DataLink do
    if Active then DataSet.MoveBy(-ActiveRecord);
end;

procedure TMyDBGrid.ScrollToLastVisible;
begin
  with DataLink do
    if Active then DataSet.MoveBy(RecordCount-ActiveRecord-1);
end;

procedure TMyDBGrid.ScrollToNVisibleRow(N: Integer);
begin
  with DataLink do
    if Active then
    begin
      if N < 1 then N := 1;
      if N > RowCount then N := RowCount;
      DataSet.MoveBy(-ActiveRecord-1+N);
    end;
end;


0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:yd
ID: 1356898
I am sorry for my little explaination!
Now I explain it detailedly.I hope you can help me!
I want to make a touch-screen program.
Because My touch-screen is 17",it must display two dbgrids
in one screen,and that two dbgrids use the same dataset.
When I click the next or prev,The first dbgrid move 10,
and the second dbgrid move next 10.
If I use moveby, that two dbgrids display the same record.
That is not my want.
So I want to  know the last record that is displayed in the first dbgrid to transfer to the second dbgrid.

can you tell me how to get the field from dbgrid and not from
dataset?

Can you tell me how can I do that?
0
 
LVL 3

Expert Comment

by:AndreasSchindler
ID: 1356899
Try to create your own component

type
  TMyDBGrid = class(TDBGrid)
  Published
   Property Toprow;
   Property VisibleRowCount;
  end;

These Propertys came from TCustomGrid. You are informed by Query/Table Afterscroll that the position has changed. By checking dbgrid.Toprow you can see if the grid has scrolled.

0
 

Accepted Solution

by:
boabyte earned 50 total points
ID: 1356900
You could use two datasets from the one table. This way you can easily keep track
of leap-frogging dbgrids.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now