Board index » delphi » Easy, easy Delphi question

Easy, easy Delphi question

A piece of cake......

I have a TDBEdit and a TDBLookupCombo on the same form (actually, a
few  of them).  Since they both have the text property in common, is
there any way to use the same identifier for both components?  (the
Sender parameter perhaps?)

Thanks,

Jim

 

Re:Easy, easy Delphi question


Quote
Java...@jaxnet.com writes:

> A piece of cake......

> I have a TDBEdit and a TDBLookupCombo on the same form (actually, a
> few  of them).  Since they both have the text property in common, is
> there any way to use the same identifier for both components?  (the
> Sender parameter perhaps?)

Probably, if your religion allows you to "downcast" types:
Would something like:

IF Sender IS TDBEdit THEN WITH Sender AS TDBEdit DO
   Text := 'new text'
ELSE IF Sender IS TDBLookupCombo THEN WITH Sender AS TDBLookupCombo DO
   Text := 'new text'

do the trick?
You'll have to do the casting if one object isn't a descendant of the
other, because the two properties only share the name in thast case.

--
-----------------------------------
Matt Francomb, Setanta Software Ltd
http://www.demon.co.uk/setanta
-----------------------------------

Other Threads