How to add a UserControl which is in a Folder in P

2019-07-09 04:17发布

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:

enter image description here

How can I access the UserControl in that folder from the ToolBox?

Rebuilding the Solution and restarting Visual Studio didn't solve my problem.

2条回答
ゆ 、 Hurt°
2楼-- · 2019-07-09 05:00

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.
查看更多
ゆ 、 Hurt°
3楼-- · 2019-07-09 05:16

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.

查看更多
登录 后发表回答