【发布时间】:2011-11-18 18:28:05
【问题描述】:
我创建了一个从 TCustomPanel 派生的组件。在那个面板上,我有一个从 TOwnedCollection 派生的类的已发布属性。一切正常,单击对象检查器中该属性的省略号会打开默认集合编辑器,我可以在其中管理列表中的 TCollectionItems。
TMyCustomPanel = class(TCustomPanel)
private
...
published
property MyOwnedCollection: TMyOwnedCollection read GetMyOwnedCollection write SetMyOwnedCollection;
end;
我还希望能够在设计时双击面板并默认打开集合编辑器。我首先创建了一个派生自 TDefaultEditor 的类并注册它。
TMyCustomPanelEditor = class(TDefaultEditor)
protected
procedure EditProperty(const PropertyEditor: IProperty; var Continue: Boolean); override;
end;
RegisterComponentEditor(TMyCustomPanel, TMyCustomPanelEditor);
这似乎是在正确的时间运行,但我一直纠结于如何启动该集合的属性编辑器。
procedure TMyCustomPanelEditor.EditProperty(const PropertyEditor: IProperty; var Continue: Boolean);
begin
inherited;
// Comes in here on double-click of the panel
// How to launch collection editor here for property MyOwnedCollection?
Continue := false;
end;
我们将不胜感激任何解决方案或不同的方法。
【问题讨论】:
标签: delphi components property-editor townedcollection