问题
I'm working on a Windows Forms project in Visual Studio 2012.
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:
How can I access the UserControl
in that folder from the ToolBox
?
Rebuilding the Solution and restarting Visual Studio didn't solve my problem.
回答1:
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:
- 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
Delete
bin
andobj
folder of your projects.- Open Visual Studio again and build solution.
回答2:
1.You can add this to you Toolbox using
Toolbox -> right click -> Choose Items -> Browse
Select your assembly with the UserControl
.
2.Build the entire solution. After that, your UserControl
should appear in the toolbox
.
来源:https://stackoverflow.com/questions/39850835/how-to-add-a-usercontrol-which-is-in-a-folder-in-project-to-toolbox