数组属性、TList、TStringList 或 TCollection 等 (Delphi Win32) [英] Array Property, TList, TStringList, or TCollection, etc (Delphi Win32)

查看:24
本文介绍了数组属性、TList、TStringList 或 TCollection 等 (Delphi Win32)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发各种组件,并且经常遇到需要具有一对多"关系的属性,即组件到属性成员.组件通常是可视组件,但并非总是如此,有时需要在 IDE 中注册(即使用 Property Inspector),但并非总是如此.我发现自己不确定在设置这些属性时应该采取哪条路线——使用数组属性、TList、TStringList、TCollection 或其他东西(可能是从其中一个继承的新类).

I am developing various components, and regularly run into the need to have a property that has a "one-to-many" relationship, component-to-property-member. The components are often visual components, but not always, and sometimes need to be registered with the IDE (i.e. use the Property Inspector), but not always. I find myself unsure of which route to take when setting up these properties -- using an array property, a TList, a TStringList, a TCollection, or something else altogether (perhaps a new class that inherits from one of those).

什么时候/在哪里使用的最佳实践"/指南是什么?

What are the "best practices" / guidelines for which to use when / where?

推荐答案

如果是属性,可以从 TCollection 继承,然后 IDE 和 Object Inspector 会通过 TCollection 属性编辑器自动为它们提供支持.

If they are properties, you can descend from TCollection, and then the IDE and Object Inspector will automatically provide support for them via the TCollection Property editor.

这篇关于数组属性、TList、TStringList 或 TCollection 等 (Delphi Win32)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆