标签: property-editor

如何在设计时调用组件的属性编辑器

我创建了一个从TCustomPanel派生的组件.在该面板上,我有一个派生自TOwnedCollection的类的已发布属性.一切运行良好,单击该属性的对象检查器中的省略号将打开默认的集合编辑器,我可以在其中管理列表中的TCollectionItems.

  TMyCustomPanel = class(TCustomPanel)
  private
  ...
  published
    property MyOwnedCollection: TMyOwnedCollection read GetMyOwnedCollection write SetMyOwnedCollection;
  end;
Run Code Online (Sandbox Code Playgroud)

我还希望能够在设计时双击面板并默认打开集合编辑器.我开始创建一个派生自TDefaultEditor的类并注册它.

  TMyCustomPanelEditor = class(TDefaultEditor)
  protected
    procedure EditProperty(const PropertyEditor: IProperty; var Continue: Boolean); override;
  end;

  RegisterComponentEditor(TMyCustomPanel, TMyCustomPanelEditor);
Run Code Online (Sandbox Code Playgroud)

这似乎是在正确的时间运行,但我仍然坚持如何在当时启动集合的属性编辑器.

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;
Run Code Online (Sandbox Code Playgroud)

任何解决方案或不同的方法将不胜感激.

delphi components property-editor townedcollection

7
推荐指数
2
解决办法
2401
查看次数