如何防止访问TCustomListView中的Items属性? [英] How do I prevent access to the Items property in TCustomListView?

查看:51
本文介绍了如何防止访问TCustomListView中的Items属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在创建的自定义组件,该组件派生自 TCustomListView

I have a custom component I am creating which is derived from TCustomListView.

我不需要商品属性发布或在运行时可通过代码访问,因为我的自定义组件将处理商品的填充和访问。

I do not need the Items property publishing or been accessible by code at runtime, as my custom component will be handling the populating and accessing of items.

我知道 UnlistPublishedProperty 可以包含在组件的 Register 过程中。因此,考虑到这一点,我尝试了:

I am aware of UnlistPublishedProperty which can be included in the Register procedure of your components. So with that in mind, I tried:

UnlistPublishedProperty(TMyListView, 'Items');

根据我的理解,以上内容仅使对象隐藏在对象检查器中,因此通过代码 MyListView1.Items 仍然存在。

From what I understand the above only makes the property hidden from the Object Inspector, and so by code MyListView1.Items is still present.

我如何制作 Items 属性(或我认为是任何属性)对用户来说是不可见,不可访问的属性,但仍可由我的组件访问?

How may I make the Items property (or any property I guess) a non visible, non accessible property to the user, yet still accessible by my component?

谢谢。 >

Thank you.

推荐答案

您不需要 UnlistPublishedProperty 即可安排不发布属性。您可以选择不发布该属性。

You don't need UnlistPublishedProperty to arrange for a property not to be published. You can simply choose not to publish the property.

要将其隐藏在代码中,同时也隐藏在设计器中,您很不幸。您可以尝试以下操作:

To hide it from code, as well the designer, you are out of luck. You might try this:

....
private
  property Items;
....

但这没有效果。从文档

可以通过重新声明属性来提高属性在后代类中的可见性,但不能降低其可见性。

You can increase the visibility of a property in a descendent class by redeclaring it, but you cannot decrease its visibility.

坦率地说,如果您希望控件不公开此属性,则不应从 TCustomListView 开始。也许您需要封装而不是继承。

Frankly if you want your control not to expose this property, you should not start from TCustomListView. Perhaps you need to encapsulate rather than inherit.

这篇关于如何防止访问TCustomListView中的Items属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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