views:

4678

answers:

7

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?

+1  A: 

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

Filip
+15  A: 

Check this setting:

Tools > Options > Windows Forms Designer > General : AutoToolboxPopulate

It should be set to True for this to work.

Kyralessa
+1  A: 

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

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

A: 

I also have this problem. What I usually do is create a new tab and add the exe/dll to that tab... Not too comfortible with that solution because of the load time and general hazzle.

A friend showed me a way to speed this up. Instead of having to click "Choose Items..." in the toolbox,etc, for each new control you make - You can create a file named MyCustomControls and there you can create your custom controls. Now you only have to do the "Choose Items..." and add this file ONCE. If you later on decide to add a new control, create it in MyCustomControls and then rebuild. Then your toolbox will have your new control. (It will be displayed automatically with a regular compile if you have AutoToolboxPopulate I think)

This is unfortunate, because often you want to separate classes into "one class per file". It is horrible that you have to ruin your code architecture just because VS doesn't want to do it your way. :)

I am not too comfortible with this solution either but if you need to do something quick and you don't care about multiple user controls within a file or just are lazy, this might suit you well. :)

DavidMB
A: 
  1. Build your project to make sure it compiles.

  2. With the form that you want your user control on, open the toolbox, right click and select "choose items"

  3. Browse to your .exe or dll that you compiled in step 1.

  4. make sure that your user control has a tick next to it, press OK.

  5. Your user control should appear in the toolbox, so drag it onto your form.

This is adapted from Calanus's answer to a similar question.

Don Kirkby
+1  A: 

In my case, the AutoToolboxPopulate was already set (Visual C# 2010 Express).

However, I had to activate "Show All" from the properties of the Toolbox (right click) to actually see my new user controls.

Maxime Larocque
A: 

Hi IN VS 2008 Toolbar there is no control visible if click on show all control it show all the controls but they are not accessible they are in gray color. i have try many solution like deleting *.tb files from local setting,run the setup form command prompt, but still problem remains same. but in asp.net project only HTML controls visible and there is no server controls visible. as well as i am trying to add new control, the error massage comes . if any buddy has a solution please welcome

Thanks in Advance Umesh

umesh rakhe