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

TCustomDBGrid::OnDrawColumnCell

20 views
Skip to first unread message

Charles Page

unread,
Sep 18, 2003, 2:32:55 PM9/18/03
to
hi all,

I was wondering if anyone has a method for determining which row is
currently being drawn (so I can stagger different color backgrounds)?

thanks,
charlie

Remy Lebeau (TeamB)

unread,
Sep 18, 2003, 2:42:58 PM9/18/03
to

"Charles Page" <lis...@snet.net> wrote in message
news:3f69fa48$1...@newsgroups.borland.com...

> I was wondering if anyone has a method for determining which
> row is currently being drawn (so I can stagger different color
backgrounds)?

The OnDrawColumnCell event handler has a TColumn parameter. TColumn has a
Field property which you can use to determine the actual TField being drawn.
TField has properties for determining its position within the DB/Recordset,
such as FieldNo and Index.


Gambit


Charles Page

unread,
Sep 18, 2003, 4:57:12 PM9/18/03
to
I am looking to determine the records row index, not it's column (or
field) index. The TDataSet::ActiveRecord property would give this, but
is protected.
(I want to run horizontal shading across rows so that all of the
information for an "object" can be easily followed across the page.)

Charlie

Remy Lebeau (TeamB)

unread,
Sep 18, 2003, 6:04:31 PM9/18/03
to
"Charles Page" <lis...@snet.net> wrote in message
news:3f6a...@newsgroups.borland.com...

> I am looking to determine the records row index, not it's column
> (or field) index. The TDataSet::ActiveRecord property would give this,
> but is protected.

You have two options:

1) Try using the Rect parameter with the inherited MouseCoord() method to
convert the pixel coordinates into row/col indexes.

2) derive a new class from TDBGrid and promote the DataLink property to
public in order to access the TDataLink::ActiveRecord property. Or derive a
new class from TDataSet and promote its ActiveRecord property to public for
accessing directly.


Gambit


Harold Howe [TeamB]

unread,
Sep 20, 2003, 12:58:41 PM9/20/03
to

> 2) derive a new class from TDBGrid and promote the DataLink property to
> public in order to access the TDataLink::ActiveRecord property. Or derive a
> new class from TDataSet and promote its ActiveRecord property to public for
> accessing directly.

If you only need access to the datalink object, consider using the
CM_GETDATALINK message. Hideous, but effective.

h^2

Harold Howe [TeamB]

unread,
Sep 20, 2003, 1:10:57 PM9/20/03
to
Charles Page wrote:

> I was wondering if anyone has a method for determining which row is
> currently being drawn (so I can stagger different color backgrounds)?

When the OnDrawColumCell event is fired, aren't you always drawing the
current row in the dataset? If this is true, can't you use the RecNo
property?

Note that RecNo is only meaningful for some datasets. For others, it
always returns -1. It does work for TClientDataSet.

h^2


Harold Howe [TeamB]

unread,
Sep 21, 2003, 1:01:03 PM9/21/03
to
Charles Page wrote:

> I was wondering if anyone has a method for determining which row is
> currently being drawn (so I can stagger different color backgrounds)?

When the OnDrawColumCell event is fired, aren't you always drawing the

current row in the dataset? If this is true, can't you use the RecNo
property?

Note that RecNo is only meaningful for some datasets. For others, it
always returns -1. It does work for TClientDataSet.

h2


Harold Howe [TeamB]

unread,
Sep 21, 2003, 1:00:37 PM9/21/03
to

> 2) derive a new class from TDBGrid and promote the DataLink property to
> public in order to access the TDataLink::ActiveRecord property. Or derive a
> new class from TDataSet and promote its ActiveRecord property to public for
> accessing directly.

If you only need access to the datalink object, consider using the

CM_GETDATALINK message. Hideous, but effective.

h2


Charles Page

unread,
Sep 21, 2003, 3:14:28 PM9/21/03
to
Thanks. I already have modified TDBGrid a bit(Borland really needs to
make so changes to that thing!), so one more change to make ActiveRecord
a public property was really simple.
charlie


0 new messages