我正在开发的一个组件使用TCollection来保存到其他组件的链接。在设计器中编辑项时,其标签如下所示:
0 - TComponentLink
1 - TComponentLink
2 - TComponentLink
3 - TComponentLink如何添加有意义的标签(可能是链接组件的名称)?例如:
0 - UserList
1 - AnotherComponentName
2 - SomethingElse
3 - Whatever另外,您能告诉我如何在双击组件时显示集合编辑器吗?
发布于 2009-10-12 10:20:27
要显示有意义的名称覆盖GetDisplayName:
function TMyCollectionItem.GetDisplayName: string;
begin
Result := 'My collection item name';
end;要在双击非可视化组件时显示集合编辑器,需要覆盖TComponentEditor编辑过程。
TMyPropertyEditor = class(TComponentEditor)
public
procedure Edit; override; // <-- Display the editor here
end;..。并注册编辑器:
RegisterComponentEditor(TMyCollectionComponent, TMyPropertyEditor);发布于 2009-09-12 14:14:50
编辑器中显示的名称存储在项的DisplayName属性中。尝试将代码设置为在创建链接时设置如下内容:
item.DisplayName := linkedItem.Name;但是,如果用户已经设置了DisplayName,请注意不要更改它。这是一个主要的UI烦恼。
https://stackoverflow.com/questions/1415193
复制相似问题