Set property for all components

Posted in Components

Change a Caption and Width properties for all components of TButton type. Realization:

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  Counter,Bt: Integer;
begin
  Bt:=0;
  for Counter:=0 to Pred(ComponentCount) do
    if Components[Counter] is TButton then
      with TButton(Component[Counter]) do
      begin
        Inc(Bt);
        Caption:='Hello '+IntToStr(Bt);
        Width:=150;
      end;