我想在VS2010下创建一个UserControl在VB.net。我有UserControl的代码,我想将它添加到表单中。我的问题是,根据我看到的每一本书和论坛,在构建UserControl之后,它应该显示在工具箱中。它没有。我甚至从书中下载代码,代码执行完美,但他们的TrafficLight控件不会在工具箱中出现(即使本书说它应该 - 并且设置其属性并将其添加到窗体的唯一方法是通过控制属性)。我曾尝试手动添加控件到窗体,宣称它VB.NET UserControl
Dim myObj As New SomeClass.SomeControl
,并在Designer.vb,与窗体上的按钮相同:
Friend WithEvents myObj As SomeClass.SomeControl
与这两个,我得到一个错误说
'myObj' is already declared as 'Friend WithEvents myObj As SomeControl' in this class.
而且无论哪种方式,我得到一个错误,当我尝试看看设计:
Could not find type 'SomeClass.SomeControl'. Please make sure that the assembly that contains this type is referenced. If this type is part of your development project, make sure the project has been successfully built using settings for your current platform or AnyCPU.
控制本身在设计视图中生成并显示(不在工具箱中,尽管它为Imports System.ComponentModel
和Inherits System.Windows.Forms.UserControl
以及...还有什么?我试图在一个单独的项目中构建它,以查看创建单独的dll是否会有所作为,尽管我真的希望它在同一个项目中。
请帮忙! (顺便说一句,我已经重新安装VS2010,它没有好处)
谢谢。
你试过右键单击工具箱并选择'Choose Items'? – Simon 2012-03-26 14:14:41