User Controls not showing up in the toolbox

2019-01-21 21:19发布

I have some UserControls that I created in ProjectA. I have ProjectB that has a windows form that I want to put the controls on. Both of these projects are in a single solution. There's a reference to ProjectA from ProjectB so it can "see" the UserControls.

However, the UserControls do not show up in the toolbox for me to drag to the windows form.

I've tried rebuilding. I've also deleted the 'bin' directory to force a rebuild-all.

How do I get VS2008 to populate the toolbox with my UserControls?

29条回答
小情绪 Triste *
2楼-- · 2019-01-21 21:39

I fell into this trap just a couple of hours ago.
I've got a .NET 2.0 Windows Application project with some custom UserControls; it worked fine. So I decided to order my files in subfolders, to make my project a little bit cleaner.
After that, Visual Studio 2010 designer stopped loading my forms, and ToolBox won't show my controls anymore.
I freaked out, moving back source files in project root, resetting ToolBox, but nothing seemed to work. After that, I remembered I used ReSharper "Remove Unused References", so I tried to put back unused reference, in particular System.Data: problem solved! :O I can't say you why, but this worked for me.
Hope my experience can help someone else. :)
Bye, Nando

查看更多
可以哭但决不认输i
3楼-- · 2019-01-21 21:39

In your UserControl, make sure that New is declared Public. It won't show up if it's just declared Sub New (which defaults to Friend).

查看更多
萌系小妹纸
4楼-- · 2019-01-21 21:40

Also double check that your user controls have a valid Namespace.

I just found that controls without namespace are not placed inside the ToolBox.

查看更多
放荡不羁爱自由
5楼-- · 2019-01-21 21:41

In my case the reason of error was an excess length of a path to my control's .dll. I had shrunk it a bit and everything became working fine.

Also I found out that the special symbols (e.g. I used #) in a path affect a control display.

Hope it solves the issue.

查看更多
可以哭但决不认输i
6楼-- · 2019-01-21 21:42

I had the same problem. After a lot of googling I did not find anything, but by chance I found out that if you click on the toolbox while you are in the same project that you have created the user control in, and check "show all", then a group with the same name as your project will appear at the top of toolbox which you can find your user control in. Now you can add your control on your desired form!

查看更多
Melony?
7楼-- · 2019-01-21 21:42

If you've tried following all the other answers and it still doesn't work, the following fixed it for me:

  • Right click on your project containing your control.
  • Select Properties.
  • In the Build settings category, make sure Register for COM interop is checked.
查看更多
登录 后发表回答