0

例如,下面是一个从 ToolboxItemAttribute 派生的简单属性:

<ToolboxItemX(False)> _
Public Class Class1
    Inherits Button
End Class

Public Class ToolboxItemXAttribute
    Inherits ToolboxItemAttribute

    Public Sub New(ByVal defaultType As Boolean)
        MyBase.New(defaultType)
    End Sub

End Class

问题是当我显示工具箱时,Class1 出现在其中。就好像我的属性被忽略了,所以使用了默认的 toolboxitem 属性。

我已经使用反射器来查看 ToolboxService.GetToolboxItem 的逻辑,据我所知,它应该获取我的属性并看到该项目不应该显示在工具箱中。

PS:我试过重置工具箱,关闭ide并重新打开等。

4

1 回答 1

1

Windows 窗体工具箱非常古怪。这应该有效,但实际上没有。不知道为什么,这段代码被锁定在 Visual Studio 中。作为一种解决方法,您可以使用 DesignTimeVisibleAttribute 将其隐藏。像这样:

<ToolboxItemX(False)> _
<DesignTimeVisible(False)> _
Public Class Class1
    Inherits Button
End Class
于 2010-09-18T15:19:08.140 回答