Do it this way - I use this method frequently - usually need it for drag and
drop as I need to access the
dragcursor property of TControl (it's protected also).

As all are descendants of TControl, you just need access to the protected
color property.
You can do this with any property that is declared in TControl - or
TWinControl if the control is a descendant of TWinControl.

TCOntrolHack = class(TControl)
public
  property Color;
end;
 for X = 0 to ControlCount do
  TcontrolHack( Controls[x]).Color := clRed;



> -----Original Message-----
> From: Laurence Bevan [SMTP:[EMAIL PROTECTED]]
> 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.
> 
> Laurence Bevan
> Master Business Systems Ltd
> 
> 
> --------------------------------------------------------------------------
> -
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to