我从来没有遇到过需要它的情况,这是我第一次尝试TCollection
拥有TCollectionItem
另一个TCollection
. TCollectionItem
这一切都编译得很好,但是当单击'TCollection
属性后面的三个点时没有反应,即。TCollection
不会出现包含该子列表的对话框。
我的印象是,由于不需要花哨的属性编辑器(子TCollection
只携带具有 astring
和 asingle
属性的项目),IDE 几乎会自动处理它。
显然情况并非如此,或者我正在监督显而易见的事情,这是一种慢性病。
实现(运行时)单元有这个:
type
TBitmapItemTag = class(TCollectionItem)
private
FTagName: string;
FTagFloat: Single;
published
property TagName: string read FTagName write FTagName;
property TagFloat: Single read FTagFloat write FTagFloat;
end;
TBitmapItemTags = class(TOwnedCollection)
end;
TBitmapItem = class(TCollectionItem)
private
FBitmap: TBitmap;
FBitmapItemTags: TBitmapItemTags;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
published
property Bitmap: TBitmap read FBitmap write FBitmap;
property Tags: TBitmapItemTags read FBitmapItemTags write FBitmapItemTags;
end;
TBitmaps = class(TCollection)
end;
TBitmapCollection = class(TComponent)
private
FBitmaps: TBitmaps;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Bitmaps: TBitmaps read FBitmaps write FBitmaps;
end;
implementation
{ TBitmapItem }
constructor TBitmapItem.Create(Collection: TCollection);
begin
inherited Create(Collection);
FBitmap := TBitmap.Create(0, 0);
FBitmapItemTags := TBitmapItemTags.Create(Self,TBitmapItemTag);
end;
destructor TBitmapItem.Destroy;
begin
FBitmap.Free;
FBitmapItemTags.Free;
inherited;
end;
{ TBitmapCollection }
constructor TBitmapCollection.Create(AOwner: TComponent);
begin
inherited;
FBitmaps := TBitmaps.Create(TBitmapItem);
end;
destructor TBitmapCollection.Destroy;
begin
FBitmaps.Free;
inherited;
end;
该Register
过程在设计时单元中实现,并且只调用该RegisterComponents
过程。RegisterPropertyEditor
并进行了一些无济于事的懒惰尝试。
如果有人能指出我的最短路径以便 IDE 识别TBitmapItemTag TCollectionItem
,我将不胜感激。