Or you can use FindComponent if you only want buttons with a certain name:

eg if you know there are 20 buttons such as bSpecial1, bSpecial2, ...
bSpecial20

var
    LButton : TButton;
...
for i := 1 to 20 do begin
    LButton := (Form.FindComponent('bSpecial' + IntToStr(i)) as TButton);
    if Assigned(LButton) then LButton.Enabled := True; // or whatever...
end;

David Brennan.
DB Solutions Ltd.

----- Original Message -----
From: "Neven MacEwan" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Friday, May 11, 2001 10:57 AM
Subject: Re: [DUG]: basic question?


> Graham
>
> for i := 0 to Form.ComponentCount-1 do
>   if Form.Components[i].InheritsFrom(TButton) then
> TButton(Form.Components[i]).Enabled:=true;
>
> HTH
>
> Neven
>
> ----- Original Message -----
> From: Graham Mayes <[EMAIL PROTECTED]>
> To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> Sent: Friday, 11 May 2001 10:41
> Subject: [DUG]: basic question?
>
>
> > I feel I must have missed something very elementary here:-
> >
> > A form has (say) 20 buttons named Button1, Button2 etc..
> > If you want to do something with each button, at the moment I write
> >    Button1.enabled:=true;
> >    Button2.enabled:=true;
> >    Button3.enabled:=true;
> >    .
> >    .
> >    etc
> >
> > How can I refer to each button in a loop?
> > eg
> >   for button_number:=1 to 20...
> >
> > TAI
> > Graham
> >
> >
>
> --------------------------------------------------------------------------
> -
> >     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> >                   Website: http://www.delphi.org.nz
> > To UnSub, send email to: [EMAIL PROTECTED]
> > with body of "unsubscribe delphi"
> >
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to