Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   TFindComponent (https://www.delphipraxis.net/214569-tfindcomponent.html)

Andreas L. 1. Feb 2024 18:38

AW: TFindComponent
 
Zitat:

Zitat von creehawk (Beitrag 1532864)
Delphi-Quellcode:
  TimeList := TStringlist.Create;
  TimeList.add('EarlyGame');
  TimeList.add('EarlyMidGame'); // <--- Hier steht was anderes als unten!
  TimeList.add('MidGame');
  // ...
...
Delphi-Quellcode:
  TListView(SellProductForm.FindComponent('EarlyGameView')).Items.Clear;   
  TListView(SellProductForm.FindComponent('EarlyMidGameView')).Items.Clear; // <--- oben steht EarlyMidGame statt EarlyMidGameView!
  TListView(SellProductForm.FindComponent('MidGameView')).Items.Clear;

Lag es vielleicht daran?

himitsu 1. Feb 2024 20:24

AW: TFindComponent
 
drum machte er ja auch
Zitat:

Zitat von creehawk (Beitrag 1532864)
Delphi-Quellcode:
FindComponent(TimeList.Strings[I]+'View')


TiGü 2. Feb 2024 09:13

AW: TFindComponent
 
Wie viele Komponenten/Listviews sind es denn in Wirklichkeit?
Bevor hier wieder so Frickel-Lösungen rumgereicht werden, tut es vielleicht auch ein Dreizeiler?

Delphi-Quellcode:
SellProductForm.EarlyGameView.Items.Clear;
SellProductForm.EarlyMidGameView.Items.Clear;
SellProductForm.MidGameView.Items.Clear;

himitsu 2. Feb 2024 09:50

AW: TFindComponent
 
Wie viele ... gute Frage ... Vorspann, Anfang, Mitte und das EndGame? :lol:

Bezeichner, anstatt doofer Strings, sind eh besser, denn da meckert schon der Compiler, wenn es diese Komponente Variable nicht gibt.
Delphi-Quellcode:
//for var LV: TListView in [EarlyGame, EarlyMidGame, MidGame] do // falls das mit der Typinferenz nicht funktioniert
for var LV in [EarlyGame, EarlyMidGame, MidGame] do
  LV.Items.Clear;
aber es gibt bestimmt noch Millionen andere Lösungen.
Delphi-Quellcode:
for var C in SellProductForm do
  if C is TListView then
    TListView(C).Items.Clear;
@Andreas: Bitte sag nicht, dass dieser Code innerhalb einer Methode von TSellProductForm liegt.


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:47 Uhr.
Seite 2 von 2     12   

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