73

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
  • 5
    I had a type Parameter in my UserControl, i.e. MyControl<T>, which meant that VS wouldn't show the control in the Toolbox. Once I got rid of the type parameter everything worked fine automatically.
    – liwp
    Feb 18, 2011 at 11:50

29 Answers 29

83

Check this setting:

Tools > Options > Windows Forms Designer > General : AutoToolboxPopulate

It should be set to True for this to work.

6
  • 13
    In VS2010 this option is enabled by default. Remember to compile your project before looking the toolbox though. If you haven't compiled it, it won't be in the list even with this option enabled.
    – Corin
    Aug 7, 2011 at 20:03
  • What do you mean by "compile"? I'm new to VS and .NET...I'm not familiar with this term. Can you please clarify? Oct 18, 2011 at 18:59
  • 7
    @Corin Also, half the time, even if you do compile with this option enabled, your control still won't show up in the toolbox. Or it might show up for a while and mysteriously disappear later (and no amount of recompilation will correct it).
    – weberc2
    Feb 4, 2013 at 16:37
  • 3
    This option is not set to True by default in VS 2014 CTP...very annoying. Dec 15, 2014 at 4:43
  • 1
    ALSO make sure your .net framework matches the hosting project you intend to use this in. And, finally remove any test forms that aren't being used in your actual user control. These were factors for me. Apr 21, 2015 at 21:29
35
  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.

4
  • It worked but I had to uncheck the UserControl between steps 2 and 3. Thanks. Oct 25, 2011 at 12:43
  • Had the issue in Visual Studio 2012.. think they'd get this figured out after a few version.
    – ScottN
    Oct 8, 2013 at 1:23
  • The second step "Choose items" >> browse >> select dll did the trick for me
    – Martin
    Nov 11, 2018 at 2:50
  • "Make sure it compiles" was the key for me. I had a couple of unrelated code errors that I planned to fix after I had my user control in place. The Internet article I read suggested you just "Add User Control" and it shows up in the toolbox. Wrong. You must an have an error free compile after adding the control. Should have gone to Stack Overflow.
    – Rodent
    Feb 29 at 23:16
21

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.

5
  • 2
    I had to do the same, except in my case they were greyed out i.e. unusable.
    – glenneroo
    Dec 12, 2010 at 16:18
  • 4
    If you "Show All" and it appears but is greyed out (i.e. you can't use it/add it) then check your class definition. I just inherited from a widget to customise some behaviour, but the default class definition had no access modifier and hence was private and so didn't show up by default. Make it public and it appears! Obvious, but easy to overlook.
    – IBBoard
    May 19, 2012 at 18:29
  • show all was interesting for me as it showed a grayed out "Text:<path to controls .cs file" but is unusable. Why is it not installing properly. Jun 8, 2012 at 13:39
  • It will also be greyed-out if it doesn't Implement iComponent msdn.microsoft.com/en-us/library/fw694kde(v=vs.80).aspx Nov 7, 2012 at 9:43
  • I tried this in 2012 but my controls still didn't show up, I had to do Don Kirkby's answer.
    – ScottN
    Oct 8, 2013 at 1:24
11

Up until now, I had no problem with usercontrols not showing in the toolbox. Build the project and it just shows up. Then today not working. After a search I went through following but still no joy.

  • Tools > Options > Windows Forms Designer > General : AutoToolboxPopulate
  • Tools > Options > Text Editor > XMAL > Misc : AutoToolboxPopulate
  • Reset the VS settings to default

So after a few hours of messing around trying to get it to work with no success, I created a new WPF windows project accepting the default name and added a usercontrol. Built the project and the user control appeared as it always had.

I then thought that something might be wrong with my project or wpf window file. Removed the project, created a new one and added a new control. Built the project but it didnt work.

The only thing I did different was choose a name for the project, which I included a space in the name "WPF Application".

Removed the project again and created a new one again called "WPFApplication" without the space and added a user control. Built it and the user control showed up.

If you want usercontrols to show up automatically in the toolbox on build, dont use spaces in the project name. Hopefully this post save's someone else a ton of wasted time.

1
  • very glad you found this out and posted your answer, thanks! I had controls that didn't show up either. After renaming the project (remove spaces in the name of the project) and a rebuild, the controls immediately showed up in the toolbox. Jul 26, 2012 at 22:33
6

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

5

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

0
5

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

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

1
  • I've also had issues with controls residing in a different namespace the the form I was trying to add them to, didn't show up in the toolbox.
    – Jeff B
    Mar 29, 2012 at 23:12
3

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!

3

For someone who might be working with ToolStripItems (e.g. ToolStripStatusLabel), to actually get your derived control to show up in the dropdown menu (such as the one from StatusStrip), you need to set the class to public then build the solution.

Also don't forget the designer attribute for your class, something like this:

using System.Windows.Forms.Design;

[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.StatusStrip)]
public class MyStatusLabel : ToolStripStatusLabel
{
}

Took me a while to get it right. Hopefully this can save someone else's time.

1
  • +1 for "you need to set the class to public then build the solution." Don't forget to set any Server/User control class to public or it won't show up in the toolbox.
    – Soenhay
    Aug 29, 2012 at 19:51
3

My control was public, it was checked in the 'Choose Toolbox Items' dialog, but it was still not showing up.

This is what finally worked for me:

Right click somewhere in the Toolbox and click 'Choose Items'. When I found my item it was already checked. I then unchecked the item and clicked okay. Next I right clicked the toolbox again and searched for my item... it was gone, so I clicked Browse, navigated to the obj/x86/debug folder and selected my exe. The item was then added correctly to the toolbox.

I think it's a VS bug.

2
  • This worked for me as well. I am building for x86 as well. Maybe that's the commonality. However, after I added the control to the form, I got an "Error loading object by folder": "Object reference not set to an instance of an object."
    – Joe Schrag
    Apr 24, 2014 at 21:32
  • The second error turned out to be code trying to run in design mode: stackoverflow.com/questions/9901987/…
    – Joe Schrag
    Apr 24, 2014 at 23:09
3

Apart all instructions that have been given(Tools > Options > Windows Forms Designer > General : AutoToolboxPopulate) + you need to build the solution (which is obvious for me) you will probably have to pay attention to the class access modifier: it MUST be PUBLIC. I just created a control and did not appeared in toolbox list and I did not knew why. So after set

public class  yourClass:control {}

than it appeared in list. ;) Hope this will help others.

2

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.

2

Here was my problem: I had added a new constructor for my control which accepted a few arguments, but I had not explicitly re-declared the empty constructor! The toolbox can only include controls which have empty constructors. In general, when you are designing a class in vb, it has an empty constructor defined implicitly (meaning you don't need to declare one). BUT, as soon as you start designing your own constructors, this empty constructor disappears, so you need to explicitly redefine it in your code! Anyways, I realize most experienced vb coder's already know all this, but hopefully this can help some newbies like myself :).

0
1

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.

1

What I usually do is create a new tab and add the exe/dll to that tab... Not too comfortable with that solution because of the load time and general hassle.

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 comfortable 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. :)

1

Well, nothing was working for me except this worked...

  1. I create a new project in my solution, and for this project it works so I was going to start using this one
  2. Playing arond, I started tweaking the xml of the csproj file to find out what was wrong with my other project in the same solution and then I reset it as it didn't seem to be working
  3. It is now magically working again in my project

Not a very good solution but you should try these steps

  1. See if it works in a brand new solution/project.
  2. See if it works in a brand new project in the same solution
  3. If #2 worked, maybe compare .csproj files...somehow mine started working again while I was doing this(this is very frustrating).
1

Providing you already tried tinkering with:

  • Tools > Options > Windows Forms Designer > General : AutoToolboxPopulate
  • Tools > Options > Text Editor > XMAL > Misc : AutoToolboxPopulate
  • created a default constructor
  • build your project / reset the toolbox and add manually your tab

Yet you still see it greyed out..

Check your path length and check the charcters being used in your absolute path.

I had a project residing in "C:\Users\myName\myCompany\R&D\Projects"
And after few hours found out that the "R&D" is the problem..
The '&' did not allow my usercontrol items to be enabled in my toolbox.

1

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

1

If you still can't find why your vstudio toolbox is not populated with your usercontrols. Then you can debug vstudio with another visual studio. Here you can find how.

1
  • Wow - given I find a bug, how would I fix it then? Jul 14, 2016 at 19:17
1

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.
1

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.

1

I was trying to build a x64 only application, so my platform target was set to x64 of course.

However, even in 2016, Visual Studio (devenv.exe) is still a 32 bit process and it cannot load 64 bit assemblies. To check the bitness of your Visual Studio, open Task Manager and check for *32 at the name of the process.

Workaround to see the Controls in the toolbox: set the platform target to Any CPU in the project settings. Do that for Debug and Release build, if necessary.

1

As mentioned here you should tell the visual studio to load your usercontrol in toolbox.

[ToolboxItem(true)]
public class PanelTitle : LabelControl  {
// Whatever code to override LabelControl here...
}
0

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).

0
0

Symptom 1: The Design Views for Form, UserControl, & Component were FAILING!

  • My Form design view was failing w/ the msg "can not find 'User Control'."
  • If I could get the Form design view to work it was very unstable & corrupted all to hell w/ any change.

Symptom 2: The UserControl & Component in the Toolbox

  • Were grayed out in the Toolbox & showed a garbled name
  • "Choose item" in the Toolbox context menu showed garbled name & no namespace

Solution: Set scope to Public in the vb behind UserControl, & Component

0

Check project path, avoid & , # etc.

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

0

When I tried to add my UserControl to the toolbox (right click toolbox, choose items, select my DLL) it would display a message saying there were no controls in my DLL.

Anyway, the problem was solved, by trying to create a form in my DLL in VS and adding the UserControl. An error message displayed saying there was no default constructor

public UserControl() {
...
}

The designer needs this because it can't know what valid arguments are. Once I added a blank constructor to the UserControl it was added to the toolbox without issue.

0

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.

-1

hello its answer Ctrl+Alt+X take this and later u have TOOLBOX :)

Not the answer you're looking for? Browse other questions tagged or ask your own question.