如何将项目中的文件夹中的UserControl添加到工具箱 [英] How to add a UserControl which is in a Folder in Project to ToolBox
问题描述
我正在使用 Visual Studio 2012 中的Windows Forms项目.
I'm working on a Windows Forms project in Visual Studio 2012.
在该项目的解决方案中,我创建了一个名为 userControls
的新文件夹,并向其中添加了一个用户控件( UserControl1
).
In the solution of the project, I created a new Folder named userControls
and added to it a user-control (UserControl1
).
这是解决方案的树状视图:
Here is the tree view of the solution:
如何从 ToolBox
访问该文件夹中的 UserControl
?
How can I access the UserControl
in that folder from the ToolBox
?
重建解决方案并重新启动Visual Studio不能解决我的问题.
Rebuilding the Solution and restarting Visual Studio didn't solve my problem.
推荐答案
成功构建后,当前项目中的用户控件将自动添加到工具箱中,而您无需执行其他任务即可.
User controls which are in the current project will be added to toolbox automatically after a successful build and you don't need to perform additional tasks to do so.
工具箱中未填充新用户控件的此类问题通常是生成错误或设计者错误.要解决该问题,您可以执行以下任务:
Such problems which the toolbox not being populated with new user controls, are usually build error or designer errors. To solve the problem you can perform these tasks:
- 关闭Visual Studio
-
删除Visual Studio设计器中的缓存文件.为此,请转到以下路径并删除所有文件夹:
- Close Visual studio
Delete Visual Studio designer cached files. To do so, go to below path and delete all folders:
%userprofile%\appdata\local\Microsoft\VisualStudio\11.0\ProjectAssemblies
删除项目的 bin
和 obj
文件夹.
这篇关于如何将项目中的文件夹中的UserControl添加到工具箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!