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条回答
闹够了就滚
2楼-- · 2019-01-21 21:56

Check project path, avoid & , # etc.

I've moved my solution from drive:\work\c#\folder\ to drive:\work\folder and it solved the problem.

查看更多
男人必须洒脱
3楼-- · 2019-01-21 21:57

Usually you need to build the solution. That almost always works for me.

查看更多
女痞
4楼-- · 2019-01-21 21:58

Another reason that user controls may not show up in the toolbox is if they do not have a default constructor.

查看更多
唯我独甜
5楼-- · 2019-01-21 21:58

Check your build output directory. If for some reason you are building your output somewhere other than the project bin\ directory, your controls won't show up in your toolbox.

查看更多
时光不老,我们不散
6楼-- · 2019-01-21 21:58

It is possible for all of the above to fail.

I fixed it by creating a new user control (TestControl) and it triggered Visual Studio to magically add my project's controls tab + controls back into the Toolbox. Then I just deleted the test control.

This happened to me after recently installing a VS 2008 automated windows update, by the way.

查看更多
做个烂人
7楼-- · 2019-01-21 21:59

Before trying to add a custom control, make sure that it is compatible with the .Net version of your current project.

I was trying to add a custom control to toolbox for a project for Windows CE 5.0 and .Net Compact v3.5 on VS2008. I did all those previous suggestions but nothing worked. The control shows up when "show all" is checked but it is grayed , even in "Choose Items" menu is checked.

I created a new project with .Net v2.0 and it worked perfectly.

查看更多
登录 后发表回答