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 FindComponent (https://www.delphipraxis.net/78401-findcomponent.html)

delphinia 4. Okt 2006 13:52


FindComponent
 
hi,

wie kann ich ALLE Objekte löschen die sich auf meienr Form befinden, die einem Bestimmten namen habe!

zb habe ich 50 Labels drauf die alle lab_1,lab_2,lab_3 usw heissen.
Dadurch das ich aber nicht weiss wieviele es wirklich sind, weiss ich nicht wie ich arbeiten soll.

Dachte an

Delphi-Quellcode:
  for x := 0 to MAXIMAL do
  begin
    (FindComponent('lab_' + IntToStr(x)) as Tlabel).Free;
  end;

aber für MAXIMAL habe ich halt keinen Wert ;([xml]

Neutral General 4. Okt 2006 13:54

Re: FindComponent
 
Delphi-Quellcode:
Maximal := Form1.ControlCount-1;
Aber vor dem Freigeben prüfen ob das was du da hast auch wirklich ein Label ist ;)

Gruß
Neutral General

Dax 4. Okt 2006 13:55

Re: FindComponent
 
Du könntest statt FindComponent zu benutzen durch die .Components iterieren und checken, ob der Name deinen Bedingungen entspricht.


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:31 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