![]() |
Property vom Typ TStrings einer neuen Komponente hinzufügen
Hi!
Also im moment versuche ich einer neuen Komponente eine Property namens Items hinzuzufügen, diese soll vom Typ TStrings bzw. TStringlist sein. Sobald ich jetzt jedoch im Objektinspektor die Property Items modifiziere (sprich: Ich schreibe ein, zwei Strings hinein) und dann das Projekt starte kriege ich Accessviolations und Delphi schmiert ab :(. Woran liegt das?? bzw. wie kann ich die Property richtig implementieren?? |
Re: Property vom Typ TStrings einer neuen Komponente hinzufü
Zitat:
|
ja das ist typisch delphi,
damit hatte ich auch meine probleme, und deshal habe ich das tutorial objekteigenschaften.rtf erstellt, dass man runterladen kann. ![]() hoffe es hift dir. |
Re: Property vom Typ TStrings einer neuen Komponente hinzufü
Zitat:
Delphi-Quellcode:
unit ControlTabs;
interface uses Windows, Messages, SysUtils, Classes, Controls, Graphics; type TControlTabs = class(TCustomControl) private FItems: TStrings; procedure SetItems(const Value: TStrings); { Private declarations } protected { Protected declarations } public constructor Create(AOwner: TComponent); override; destructor Destroy; override; { Public declarations } published { Published declarations } property Items: TStrings read FItems write SetItems; end; procedure Register; implementation procedure Register; begin RegisterComponents('CR-Soft', [TControlTabs]); end; { TControlTabs } constructor TControlTabs.Create(AOwner: TComponent); begin inherited Create(AOwner); FItems := TStringList.Create; end; procedure TControlTabs.SetItems(const Value: TStrings); begin FItems := Value; // SetLength(FButtons, FItems.Count); //FButtons: Array of TRect end; destructor TControlTabs.Destroy; begin FItems.Free; inherited; end; end. |
SetItems sollte so ausschaun:
Delphi-Quellcode:
procedure TControlTabs.SetItems(const Value: TStrings);
begin FItems.Assign(Value); end; |
:hello: danke motzi, klappt wunderbar :thumb:
das passiert wenn man sich ganz faul die prozeduren von delphi schreiben lässt :oops: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:23 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