Tôi đang cố tạo một thành phần tùy chỉnh với thuộc tính bộ sưu tập. Tuy nhiên, nếu tôi cố gắng mở trình chỉnh sửa bộ sưu tập trong thời gian thiết kế bằng cách nhấp vào nút "..." trong trình kiểm tra đối tượng, thì không có gì xảy ra. Những gì tôi đang mất tích?Sử dụng hậu duệ TownedCollection trong Delphi
Dưới đây là hậu duệ của tôi TCollection:
TMyCollection = class(TOwnedCollection)
private
function GetItem(Index: Integer): TMyCollectionItem;
procedure SetItem(Index: Integer; const Value: TMyCollectionItem);
public
function Add : TMyCollectionItem;
property Items[Index: Integer]: TMyCollectionItem read GetItem write SetItem;
end;
Và mục:
TMyCollectionItem = class(TCollectionItem)
private
FValue: integer;
protected
function GetDisplayName: string; override;
public
procedure Assign(Source: TPersistent); override;
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
published
property Value : integer read FValue write FValue;
end;
Cảm ơn, điều đó đã giúp tôi phát hiện lỗi: Tôi không gọi RegisterClass và tôi gặp lỗi trong hàm tạo khiến trường nội bộ cho bộ sưu tập không phải là số không. – Harriv
Không sao cả, tôi rất vui được giúp đỡ. –