Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Label Captionen mit "kurzem" qt ändern (https://www.delphipraxis.net/20344-label-captionen-mit-kurzem-qt-aendern.html)

citybreaker 16. Apr 2004 10:41


Label Captionen mit "kurzem" qt ändern
 
Hallo,

ich das 10 Labels schnell die gleiche caption bekommen deswegen hab ich gedacht
ich mach das mit for, alerdings klappt das nicht wie ich es mir gedacht hab.

Delphi-Quellcode:
var i, i1: integer;
begin
  i1 := 10;
  for i := 1 to i1 do
    Label[i].Caption :='11';
end;
Wie könnte ich das sonst möglichst kurz machen?

Matze 16. Apr 2004 10:42

Re: Label Captionen mit "kurzem" qt ändern
 
Such mal hier nach Hier im Forum suchenFindComponent

Meflin 16. Apr 2004 10:43

Re: Label Captionen mit "kurzem" qt ändern
 
Delphi-Quellcode:
with TLabel(FindComponent('label'+inttostr(variable))) do begin
...
end;

Markus K. 16. Apr 2004 10:44

Re: Label Captionen mit "kurzem" qt ändern
 
Hallo citybreaker,
nutze dafür FindComponent.
Delphi-Quellcode:
var i, i1: integer;
begin
  i1 := 10;
  for i := 1 to i1 do
    TLabel(FindComponent('Label'+IntToStr(Lauf))).Caption:='...';
end;
Tschüß Markus

StefanDP 16. Apr 2004 11:20

Re: Label Captionen mit "kurzem" qt ändern
 
ich bevorzuge folgenden syntax:

Code:
for i := 1 to il do
  (FindComponent('Label' + IntToStr(i) as TLabel)).Caption := '...'
mfg
stefan

citybreaker 16. Apr 2004 11:42

Re: Label Captionen mit "kurzem" qt ändern
 
Hab schon was gefunden, nachdem matze das mit findcomponent geschrieben hat. Danke für eure hilfe. :dance:


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:58 Uhr.

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