隐藏财产 [英] Hiding a Property
问题描述
大家好
我正在开发一个控件,我需要隐藏一些属性给
用户。例如,假设我需要Text属性完全
inacessible(从进入另一个项目/程序集的Form / Code)。
我尝试过属性:
<可浏览(错误),_
EditorBrowsable(EditorBrowsableState.Never),_
RefreshProperties(RefreshProperties。重绘),_
描述("获取或设置控件的文本值。)_
公共阴影属性Text()As String
获取
返回MyBase.Text
结束获取
设置(ByVal Value As String)
如果MyBase.Text< Value Then
MyBase.Text = Value
结束如果
结束集
结束财产
但我发现Text属性是由物品
浏览器隐藏的,但它仍然可以通过IntelliSense访问。
然后,我尝试联系设计师:
受保护的覆盖Sub PostFilterProperties(ByVal属性为
IDictionary)
properties.Remove(" Text")
MyBase.PostFilterProperties(properties)
End Sub
但是,再次,IntelliSense可以访问Text属性。
有什么问题?
谢谢。
Dom
Hi all
I''m developing a control, and I need to hide some properties to the
user. For example, suppose I need Text property to be completely
inacessible (from a Form/Code that is into another project/assembly).
I tried with attributes:
<Browsable(False), _
EditorBrowsable(EditorBrowsableState.Never), _
RefreshProperties(RefreshProperties.Repaint), _
Description("Gets or sets the control''s Text value.")_
Public Shadows Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
If MyBase.Text <Value Then
MyBase.Text = Value
End If
End Set
End Property
but I discovered that Text property is invisible by the property
browser, but it is still accessible through IntelliSense.
Then, I tried associating a designer:
Protected Overrides Sub PostFilterProperties(ByVal properties As
IDictionary)
properties.Remove("Text")
MyBase.PostFilterProperties(properties)
End Sub
but, again, the Text property is accessible by IntelliSense.
What''s wrong?
Thank you.
Dom
推荐答案
您可能会考虑私人物业`
你也可以选择申报只获取或设置私人
问候
Michel Posseth
" Dom" < do ***************** @ gmail.comschreef in bericht
news:u3 ************* *@TK2MSFTNGP06.phx.gbl ...
You might consider private property`s
you can also choose to declare only the get or set private
regards
Michel Posseth
"Dom" <do*****************@gmail.comschreef in bericht
news:u3**************@TK2MSFTNGP06.phx.gbl...
大家好
我正在开发一个控件,我需要隐藏一些对用户的属性。
例如,假设我需要Text属性完全无法使用
(来自进入另一个项目/程序集的表单/代码)。 />
我尝试过属性:
<可浏览(错误),_
EditorBrowsable(EditorBrowsableState.Never), _
RefreshProperties(RefreshProperties.Repaint),_
描述("获取或设置控件的文本值。)_
Public Shadows属性Text()As String
获取
返回MyBase.Text
结束获取
Set (ByVal Value As String)
如果MyBase.Text< Value Then
MyBase.Text = Value
结束如果
结束集
结束正确ty
但是我发现Text属性对于属性浏览器是不可见的,
但它仍然可以通过IntelliSense访问。
然后,我尝试联系设计师:
受保护的覆盖Sub PostFilterProperties(ByVal属性为
IDictionary)
properties.Remove( 文本)
MyBase.PostFilterProperties(属性)
结束子
但是,同样可以访问Text属性通过智能感知。
怎么了?
谢谢。
Dom
Hi all
I''m developing a control, and I need to hide some properties to the user.
For example, suppose I need Text property to be completely inacessible
(from a Form/Code that is into another project/assembly).
I tried with attributes:
<Browsable(False), _
EditorBrowsable(EditorBrowsableState.Never), _
RefreshProperties(RefreshProperties.Repaint), _
Description("Gets or sets the control''s Text value.")_
Public Shadows Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
If MyBase.Text <Value Then
MyBase.Text = Value
End If
End Set
End Property
but I discovered that Text property is invisible by the property browser,
but it is still accessible through IntelliSense.
Then, I tried associating a designer:
Protected Overrides Sub PostFilterProperties(ByVal properties As
IDictionary)
properties.Remove("Text")
MyBase.PostFilterProperties(properties)
End Sub
but, again, the Text property is accessible by IntelliSense.
What''s wrong?
Thank you.
Dom
Michel Posseth [MCP]说以下On 08/09/2006 16.07:
Michel Posseth [MCP] said the following On 08/09/2006 16.07:
您可能会考虑私有财产的
You might consider private property`s
这似乎无法解决我的问题:如果是继承的
属性(如Text)私有财产声明只需简单地制作
智能感知节目e parent property。
This does not seems to solve my problem: in case of an inherited
property (such as Text) a private property declaration simply make
IntelliSense show the parent property.
你也可以选择只声明获取或设置私人
you can also choose to declare only the get or set private
对不起,我不明白你的意思......
谢谢你的回复。
Dom
Sorry, I don''t understand what you mean...
Thank you for reply.
Dom
我有同样的问题,并没有找到任何强制Intell的解决方案...
没有显示它。我所做的是在我的控件中隐藏属性然后如果用户
尝试设置它,只是忽略它或强制错误。但是,我认为用户
实际上可以通过反射在基本控件中设置属性。
-
Dennis in Houston
" Dom"写道:
I have the same problem and have not found any solution to force Intell... to
not show it. What I do is shadow the property in my control then if the user
tries to set it, just ignore it or force an error. However, I think the user
can actually set the property in the base control thru reflection.
--
Dennis in Houston
"Dom" wrote:
Michel Posseth [MCP]说以下On 08/09/2006 16.07:
Michel Posseth [MCP] said the following On 08/09/2006 16.07:
您可以考虑私有财产的
You might consider private property`s
这似乎无法解决我的问题:如果是继承的
属性(例如Text) )私有财产声明只需简单地生成
IntelliSense显示父属性。
This does not seems to solve my problem: in case of an inherited
property (such as Text) a private property declaration simply make
IntelliSense show the parent property.
你也可以选择只声明获取或设置私有
you can also choose to declare only the get or set private
对不起,我不明白你的意思......
谢谢你的回复。
Dom
Sorry, I don''t understand what you mean...
Thank you for reply.
Dom
这篇关于隐藏财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!