![]() |
TLabel.create parent probleme
hallo
Ich möchte gerne eine label dynamisch generieren. Das ParentConrol muss ja von Type TWinControl sein. Wie komme ich da ran? lFrom ist vom Type TForm und darauf befindet sich ein Panel auf welchem ich ein Label positionieren möchte.
Delphi-Quellcode:
lComponent := lForm.FindComponent('Panel'); lValueLabel := TLabel.Create(lComponent); lValueLabel.Parent := lComponent; //->> funktioniert so nicht, da lComponent vom Type TComponent ist. |
Re: TLabel.create parent probleme
Zitat:
|
Re: TLabel.create parent probleme
Moin day,
dazu musst Du nur einen TypeCast durchführen. Sollte so funktionieren:
Delphi-Quellcode:
lValueLabel.Parent := lComponent as TWinControl;
|
Re: TLabel.create parent probleme
Hallo,
du musst nur kontrollieren ob die Komponente vom Typ TWinControl ist und dann nach diesem Typ casten!
Delphi-Quellcode:
lComponent := lForm.FindComponent('Panel');
lValueLabel := TLabel.Create(lComponent); if lComponent is TWinControl then lValueLabel.Parent := TWinControl(lComponent); |
Re: TLabel.create parent probleme
danke hat funkioniert
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:20 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