加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

在Delphi编辑器中更改TCollectionItem的标签

发布时间:2020-12-15 09:23:48 所属栏目:大数据 来源:网络整理
导读:我正在处理的组件使用TCollection来保存到其他组件的链接.在设计器中编辑项目时,它们的标签看起来像这样: 0 - TComponentLink1 - TComponentLink2 - TComponentLink3 - TComponentLink 如何添加有意义的标签(可能是链接组件的名称)?例如 0 - UserList1 - A
我正在处理的组件使用TCollection来保存到其他组件的链接.在设计器中编辑项目时,它们的标签看起来像这样:

0 - TComponentLink
1 - TComponentLink
2 - TComponentLink
3 - TComponentLink

如何添加有意义的标签(可能是链接组件的名称)?例如

0 - UserList
1 - AnotherComponentName
2 - SomethingElse
3 - Whatever

作为奖励,您能告诉我如何在双击组件时显示集合编辑器吗?

解决方法

要显示有意义的名称,请覆盖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);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读