One possibility is something like

if x is TDBEdit then
 with x as TDBEdit do...
else
  if x is TdbCheckBox then
   with x as TDBCheckBox do

typecasting each control as this is the only way you will be able to access
its full properties

alternatively
if x is TDBEdit
  then
  begin
         y:=TDBEdit(x)...
end
else...

there may be a less messy way than multiple if-then-else statements

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Laurence Bevan
> Sent: Wednesday, 13 October 1999 21:43
> To: Multiple recipients of list delphi
> Subject: [DUG]: Changing control style
>
>
> I have a panel which has a number of controls (dbedits,
> dbcheckbox, etc) and
> I want to change the background colour of each control when the Insert
> button is clicked. I've tried using the Controls property like so:
>
>   for x := 0 to Panel5.ControlCount - 1 do
>   begin
>     MyControl := Panel5.Controls[x];
>     MyControl.Color := clRed;
>   end;
>
>  but Color is a protected property of TControl. Is there any other way of
> doing this without hard-coding each individual control. I also want to
> change the colour back when the new record is posted.

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to