Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

the last record that is displayed in the dbgrid?

Posted on 1998-07-01
6
Medium Priority
?
312 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 150 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

721 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