2008. január 1., kedd

Color all controls on a form at runtime


Problem/Question/Abstract:

I want to color form controls at runtime without knowing beforehand how many and what controls there are.

Answer:

type
  TControlCracker = class(TControl);

procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
begin
  for I := 0 to ComponentCount - 1 do
    if Components[I] is TControl then
      TControlCracker(Components[I]).Color := clLime;
end;

Nincsenek megjegyzések:

Megjegyzés küldése