![]() |
TCollection: Problem bei Verwendung in Komponente
Hey,
ich habe eine Komponente, der ich eine Eigenschaft vom Collection Typ gegeben habe.
Delphi-Quellcode:
MyCollection und MyCollectionItem haben folgende Methoden:
property MyCol: TMyCollection read FMyCol write FMyCol;
Delphi-Quellcode:
Klapt auch alles soweit, dass die Property im OI angezeigt wird und dass ich Items hinzufügen und entfernen kann. Leider klapt es nicht einem Item einen Wert zur Designtime zuzuweisen. Erstmal habe ich im OnCreate meiner Komponente Code drinnen, der 2 CollectionItems hinzufügt und Irgendwas setzt.
type
TMyCollectionItem = class(TCollectionItem) private FIrgendwas: String; function GetDisplayName: String; override; protected public published property Irgendwas: String read FIrgendwas write FIrgendwas; end; TMyCollection = class(TCollection) private function GetItem(Index: Integer): TMyCollectionItem; procedure SetItem(Index: Integer; Value: TMyCollectionItem); protected public function Add: TMyCollectionItem; property Item[Index: Integer]: TMyCollectionItem read GetItem; published end; Die Items sehe ich dann auch zur Designtime, aber Irgendwas ist leer. Setze ich jetzt Irgendwas z.b auf "test" und frage den Wert zur Laufzeit ab, so ist dieser wieder leer. :pale: Weiß jemand, woran das liegen könnte? Gruß Zacherl |
Re: TCollection: Problem bei Verwendung in Komponente
Wird TMyCollection.Create mit TMyCollectionItem als Parameter aufgerufen?
|
Re: TCollection: Problem bei Verwendung in Komponente
Ja ..
|
Re: TCollection: Problem bei Verwendung in Komponente
Was steht in der .dfm?
|
Re: TCollection: Problem bei Verwendung in Komponente
Da scheint es korrekt eingetragen zu sein:
Code:
Wobei ich nicht verstehe, warum die im OnCreate des TdxICQClient zugewiesenen Capabilites nicht eingetragen werden. Da geht es mit:
object Form2: TForm2
Left = 0 Top = 0 Caption = 'Form2' ClientHeight = 284 ClientWidth = 418 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object dxICQClient1: TdxICQClient LoginHost = 'login.icq.com' Capabilities = < item end item end item Capability = 'test' end item end item end item end item end item end item end item end> ClientDetection = <> Left = 152 Top = 112 end end
Delphi-Quellcode:
FCapabilities.Add.Capability := 'irgendwas';
|
Re: TCollection: Problem bei Verwendung in Komponente
So, hatte vergessen bei der Items Property den Setter SetItem auch anzugeben. Klapt allerdings immer noch nicht :evil:
Weise ich allerdings zur Laufzeit einem Item einen Wert zu, so wird dieser auch korrekt ausgegeben. Nur zur Designtime will es nicht funktionieren. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:09 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 by Thomas Breitkreuz