2012-03-23 70 views
1

我想在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.ComponentModelInherits System.Windows.Forms.UserControl以及...还有什么?我试图在一个单独的项目中构建它,以查看创建单独的dll是否会有所作为,尽管我真的希望它在同一个项目中。
请帮忙! (顺便说一句,我已经重新安装VS2010,它没有好处)
谢谢。

+0

你试过右键单击工具箱并选择'Choose Items'? – Simon 2012-03-26 14:14:41

回答

1

看在工具/选项/ Windows窗体设计器和“AutoToolboxPopulate”设置为True(但请注意,这可能需要的时间明显金额,如果你废话多(即用户控制的几十个)。

+0

非常感谢,它帮助我进行了很多故障排除。有没有想过为什么控制器会显示在x86中,而不是x64中? – Thalia 2012-03-29 22:22:36

+0

否 - 从未听说过这种怪异之前! – 2012-03-31 09:48:23