【发布时间】:2016-08-09 11:28:29
【问题描述】:
注意:我放置 C# 标签是为了更清楚地了解这个问题,作为 在 C# 中回答对我来说很好,我将能够将它翻译成 VB 。网。我面临的问题是 .NET Framework 中的概念。
我目前正在编写一个图形设计器,以便用户可以将我自己的一组自定义组件添加到设计界面中,按照他们的意愿排列它们,然后将其保存到文本文件中。
大部分情况下它工作正常,但我尝试使用自定义设计器来隐藏一些我不想向用户显示的属性:
Public Class MyDesigner
Inherits ComponentDesigner
Public Overrides Sub Initialize(component As IComponent)
MyBase.Initialize(component)
End Sub
'These are the properties I will hide
' (real list is way longer)
Private _hiddenPropertyList As String() = { _
"AccessibleRole", _
"AccessibleDescription", _
"AccessibleName", _
}
Protected Overrides Sub PreFilterProperties(properties As IDictionary)
MyBase.PreFilterProperties(properties)
For Each PropName As String In _hiddenPropertyList
If properties.Contains(PropName) Then
'We hide the properties that are in the list
properties.Remove(PropName)
End If
Next
End Sub
End Class
所以这并不复杂。要激活我的设计器,我必须在组件类定义中将其设置为属性:
<Designer(GetType(MyDesigner))>
Public Class MyLabel
Inherits Label
Public Sub New()
MyBase.New()
End Sub
End Class
所以这也不是很复杂。
问题
问题是,当在设计表面上创建一个新的MyLabel 并且我设置了DesignerAttribute 时,它会显示在表面下方,如图所示:
这是我删除 DesignAttribute 时的结果:
这是我真正想要显示的内容。
我的问题
为了完成这项工作,我在这里缺少什么?
【问题讨论】:
-
嗯,看起来很奇怪。由于某种原因,当您应用设计器属性时,您的标签被添加为组件而不是实际控件。
标签: c# .net vb.net design-surface