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 auf andere Unit (https://www.delphipraxis.net/151018-findcomponent-auf-andere-unit.html)

jangbu 3. Mai 2010 11:26


FindComponent auf andere Unit
 
Hallo,

Delphi-Quellcode:
var acomp : TComponent;
beging
  for i:=1 to 10 do
  begin
    acomp := FindComponent('Panel'+IntToStr(i));
    if acomp <> nil then
      (acomp as TPanel).Color := clRed;
end;
geht solange ich eine Komponente (TPanel) aus der aktiellen Unti abfrage. Frage ich jedoch eine Komponente aus einer anderen Unit des Projektes ab:

Delphi-Quellcode:
    { incl. Unit-Name } 
    acomp := FindComponent('Form1.Panel'+IntToStr(i));
bekomme ich immer nil zurück, also die Komonente wird nicht gefunden?
Wie kann ich dynamisch auf Komponenten anderer Units zugreifen?

Danke
jangbu

[edit=mkinzler]Delphi-Tags eingefügt Mfg, mkinzler[/edit]

dominikkv 3. Mai 2010 11:34

Re: FindComponent auf andere Unit
 
FindComponent ist eine Methode deiner Form und hat mit Units eher weniger zu tun.
Delphi-Quellcode:
acomp := Form1.FindComponent('Panel'+IntToStr(i));

jangbu 3. Mai 2010 12:27

Re: FindComponent auf andere Unit
 
Super!
Danke dominikkv
jangbu


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