Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

first and last row in a DBGrid

2,081 views
Skip to first unread message

Stark

unread,
Feb 8, 2010, 10:55:40 AM2/8/10
to
On the push of a button by the user, I would like to make changes to all of
the records of a dataset curenly visible on a DBGrid.
I need a way to identify the visible rows in order to apply a filter or run
a query on the dataset. How do I know the first and the last DBGrid rows ?

alang...@aol.com

unread,
Feb 8, 2010, 11:20:57 AM2/8/10
to

From TDBGrid's ancestor . . .

TCustomGrid >> TDBGrid.TopRow
TCustomGrid >> TDBGrid.VisiblrRowCount

Alan Lloyd

Stark

unread,
Feb 11, 2010, 10:14:09 AM2/11/10
to
I don't find these properties anywhere, Alan.
Can you be more explicit ? Thanks

<alang...@aol.com> ha scritto nel messaggio
news:d566e233-4f27-48cf...@f8g2000yqn.googlegroups.com...

alang...@aol.com

unread,
Feb 12, 2010, 10:20:11 AM2/12/10
to
On 11 Feb, 15:14, "Stark" <franco.jo...@tin.it> wrote:
> I don't find these properties anywhere, Alan.
> Can you be more explicit ? Thanks

Look in Delphi Help for TDBGrid and Heirarchy. You will see that
TDBGrid is descended from TCustomDBGrid & TCustom Grid. Click on
TCustomGrid & then click on Properties in TCustomGrid. You will see
TopRow & VisibleRowCount in the list with (in D3) a yellow square
showing they are Protected properties.

Protected properties are not exposed (ie made available) except
explicitly by a descendant class _OR_ by typecasting to a new
descendant class. So you cannot (as you have found) access them as
properties of a TDBGrid.

But you can access them by declaring a descendant class of TDBGrid
(any name but I usually use a name meaningful for the purpose) :-

class
TDBGridRows = class(TDBGrid);

Then you can access the properties by :-

MyTopRow := TDBGridRows(TDBGrid).TopRow;
MyVisibleRows := TDBGridRows(TDBGrid).VisibleRowCount;

Protected & private properties are always there, but the compiler
prevents you accessing them unless you cheat <g>.

Alan Lloyd

Stark

unread,
Feb 16, 2010, 8:22:12 AM2/16/10
to
Thanks a lot. You have the gift of concreteness and clarity.

<alang...@aol.com> ha scritto nel messaggio

news:7684f21c-0a4a-4139...@k41g2000yqm.googlegroups.com...

0 new messages