Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how would you do this ? 1

Status
Not open for further replies.

DelphiAaron

Programmer
Jul 4, 2002
826
AU
say you have 10 buttons called button1, button2 ext..

then you want to change the caption on all the buttons
like this

var a:integer;
begin
a:=1;
repeat
button(a).caption:='hello';
until a=10;
end;

how would you go about it ?

Aaron Taylor
John Mutch Electronics
 
Something like this will work:
Code:
var
  i: Integer;
begin
  for i := 0 to ControlCount - 1 do
    if Controls[i] is TButton then
      (Controls[i] as TButton).Caption := 'MyButton';
end;

Also take a look at Components in the Delphi help as an alternative to Controls - it depends exactly what you're trying to do.

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top