How to add a UserControl which is in a Folder in Project to ToolBox

余生长醉 提交于 2019-12-11 00:02:05

问题


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\Proj‌​ectAssemblies 
    
  • Delete bin and obj 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!