Something along these lines:
For Counter := 1 to Form1.Controlscount do
Begin
If Form.Controls[Counter - 1] is TButton then
with Form.Controls[Counter - 1] as TButton do
Begin
//whatever you want to do
end;
inc(Counter) //cannot recall if you need to do this
end;
-----Original Message-----
From: Graham Mayes [mailto:[EMAIL PROTECTED]]
Sent: 11 May 2001 10:42
To: Multiple recipients of list delphi
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"