Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Button (variabel) Caption ändern (https://www.delphipraxis.net/77844-button-variabel-caption-aendern.html)

dm007 25. Sep 2006 17:36


Button (variabel) Caption ändern
 
Hallo,

wieder mal ne Anfängerfrage.

Ich habe 10 Buttons (Name: Button1, Button2, Button3 ...)
Jetzt möchte ich die Caption in einer Schleife ändern.

Bsp:

Code:
var
i : integer;

begin
  For i := 1 to 10 do
    begin
      Button[i].Caption := IntToStr[i];
    end;
end;
Geht sowas ???

Gruß DM007

Balu der Bär 25. Sep 2006 17:37

Re: Button (variabel) Caption ändern
 
Hier im Forum suchenFindComponent

dm007 25. Sep 2006 18:22

Re: Button (variabel) Caption ändern
 
Deine Antwort war zwar kurz, aber ich habs rausgefunden.

Delphi-Quellcode:
var
i : integer;
const
  NamePrefix = 'Button';

begin
  For i := 1 to 10 do
    begin
      TButton(FindComponent(NamePrefix + IntToStr(i))).Caption := IntToStr(i);
    end;
end;
Danke

Gruß DM007


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:24 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz