Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Delphi IsEmpty = True bei List.Count = 1 (https://www.delphipraxis.net/214639-isempty-%3D-true-bei-list-count-%3D-1-a.html)

haentschman 14. Feb 2024 07:42

IsEmpty = True bei List.Count = 1
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallöle...8-)

...verstehe ich nicht (siehe Bild). :roll:

Die WebFleetList ist eine abgeleitete TObjectList<TWebFleet>. In der Liste ist ein Objekt drin. Verschiedene Buttons (Delete z.b.) sind abhänging vom Inhalt der Liste. Ich wunderte mich, warum der Button disabled war, obwohl die Liste NICHT leer ist. :gruebel:

Ich benutze gern
Delphi-Quellcode:
not List.IsEmpty
statt
Delphi-Quellcode:
List.Count > 0
... das geht aber gerade in die Hose.

Hat Jemand eine Erklärung?

Danke...:wink:

himitsu 14. Feb 2024 08:22

AW: IsEmpty = True bei List.Count = 1
 
Wo kommt DIESES FIsEmpty denn her?

Zitat:

Delphi-Quellcode:
property IsEmpty: Boolean read GetIsEmpty;

function TList<T>.GetIsEmpty: Boolean;
begin
  Result := FCount = 0;
end;


haentschman 14. Feb 2024 08:40

AW: IsEmpty = True bei List.Count = 1
 
Zitat:

Wo kommt DIESES FIsEmpty denn her?
...aus TList<> :zwinker:

Ich habe KEIN eigenes IsEmpty implementiert. Meine Objektliste Liste erbt von TList.

Nachtrag:
Ich habe gelogen. Ich hätte schwören können, daß das IsEmpty aus TList kommt. :oops:

Tatsache seit 5 Jahren:
Delphi-Quellcode:
  TxxxxObjectList<T: class> = class(TObjectList<T>)
  strict private
  {$REGION 'Fields'}
    FChanged: Boolean;
    FIsLoading: Boolean;
    FIsEmpty: Boolean;
    FOnChange: TOnChangeEvent;
    procedure SetChanged(const Value: Boolean);
    procedure SetIsLoading(const Value: Boolean);
  {$ENDREGION}
  public
    constructor Create; overload; virtual;
    constructor Create(const AComparer: IComparer<T>); overload; virtual;
    property OnChange: TOnChangeEvent read FOnChange write FOnChange;
    property Changed: Boolean read FChanged write SetChanged;
    property IsLoading: Boolean read FIsLoading write SetIsLoading;
    property IsEmpty: Boolean read FIsEmpty write FIsEmpty; // -> würg
    procedure Clear; overload;
    function Add(const Value: T): Integer; overload;
    procedure Delete(Index: Integer); overload;
    function Remove(const Value: T): Integer; overload;
  end;
...wer mach denn so einen Schei...:oops:

freimatz 19. Feb 2024 14:22

AW: IsEmpty = True bei List.Count = 1
 
Der MMX? :duck:
(wenn man die entsprechenden Optionen auswählt)


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