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

Identifying Data-aware Controls linked to a Datasource

0 views
Skip to first unread message

David Lapsley

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to
Hi,

What is the best way to identify all Data-aware controls which are 'bound'
to a particular Datasource. i.e. have their Datasource property set to a
specific datasource object?

At present I loop through all the form's components looking for DBEdits,
DBCombos etc and check their datasource property (requires typecasting etc)
but I feel that the datasource must know internally what controls it is
maintaining!!

Thanks
David

Peter Below (TeamB)

unread,
Oct 20, 2000, 3:00:00 AM10/20/00
to
In article <39ef34ab_2@dnews>, David Lapsley wrote:
> What is the best way to identify all Data-aware controls which are 'bound'
> to a particular Datasource. i.e. have their Datasource property set to a
> specific datasource object?
You can iterate over the components on the form using the components array
and use run-time type information with routines from the TypInfo unit (see
source) to figure out which components have a Datasource property and get its
value.

> At present I loop through all the form's components looking for DBEdits,
> DBCombos etc and check their datasource property (requires typecasting etc)
> but I feel that the datasource must know internally what controls it is
> maintaining!!

It does, but the link is indirect. TDatasource has a protected property that
gives access to its internal list of TDatalink references. You could walk
over this list, check if the datalink you have is a TFieldDatalink and if it
is use the links COntrol property to get at the control the link belongs to.
See source in db.pas, dbctls.pas.

Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!


0 new messages