![]() |
tstrings als property
Hi,
Delphi-Quellcode:
Sollte doch ohne Probleme gehen, oder? Wenn ich aber im OI den TStrings-Editor öffnen will, kommt folgendes:
type
Tblabla = class(TComponent) private ... fComment: TStrings; ... procedure SetComment(Value: TStrings); published property Comment: TStrings read fComment write SetComment; constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; ... procedure TMozillaCookies.SetComment(Value: TStrings); begin fComment.Assign(Value); end; Zitat:
|
Re: tstrings als property
Delphi-Quellcode:
mfG
procedure TMozillaCookies.SetComment(Value: TStrings);
begin if Value <> nil then fComment.Assign(Value); // eventuell: // else fComment.Clear; end; mirage228 |
Re: tstrings als property
Danke für deine Antwort aber der Fehler kommt immer noch. Noch eine Idee :?:
|
Re: tstrings als property
Der Fehler kommt auch eher beim Auslesen der Eigenschaft.
|
Re: tstrings als property
Hallo,
Zitat:
Gruß Hawkeye |
Re: tstrings als property
Zitat:
mfG mirage228 |
Re: tstrings als property
Zitat:
Delphi-Quellcode:
function TMozillaCookies.GetComment:TStrings;
begin Result := fComment; end; |
Re: tstrings als property
Zitat:
|
Re: tstrings als property
Zitat:
|
Re: tstrings als property
Zitat:
Delphi-Quellcode:
fComment := TStrings.create;
//fComment.create; ebenfalls |
Re: tstrings als property
Zitat:
Delphi-Quellcode:
heißen.
fComment := TStringList.create;
|
Re: tstrings als property
Zitat:
Zitat:
mfG mirage228 |
Re: tstrings als property
Weil TStrings eine abstrakte Klasse ist, sprich, sie definiert nur ein Grundgerüst, welches dann z.B. bei einer TStringList verwendet wird, und so verschiedenen Ansammlungen von Listen eine gemeinsame (und kompatible) Basis schafft.
Du wirst vermutlich *argh* roter Kasten, siehe mkinzler mfG Markus |
Re: tstrings als property
Es klappt! Wusste nicht das ich TStrings als TStingList erstellen muss. Danke an alle! :???: :thumb:
|
Re: tstrings als property
TStrings ist eine abstrakte Basisklasse. TStringList implementiert.
|
Re: tstrings als property
Wenn du fComment im Konstruktor erstellst, bitte nicht vergessen, im Destruktor wieder freizugeben.
Aber VOR inherited! (im Konstruktor NACH inherited) Nur so als kleiner Hinweis, falls du es nicht schon so gemacht hast... |
Re: tstrings als property
Ok, jetzt kann ich Comment ganz normal im OI verwenden. Möchte ich aber jetzt den "Comment" in ein memo haben meldet mir der Compiler
Zitat:
Mein Code:
Delphi-Quellcode:
Hää?? Comment ist doch im published-Abschnitt meiner Komponente deklariert... :gruebel:
memo1.Assign(mozillacookies1.Comment);
|
Re: tstrings als property
Muss es nicht Memo1.Lines.... heißen?
|
Re: tstrings als property
Zitat:
|
Re: tstrings als property
Hat sich erledigt. Es gab noch eine gleichnamige Unit in einen anderen Suchpfad.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:43 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