How to put a UserControl into Visual Studio toolBox

Viewed 155898

I made a usercontrol in my project, and after building project, I need to put it in my toolbox, and use it as a common control. but i can't. the UserControl is in my project namespace, and I tried Choose Item in right click menu, but I didn't find a way to add it.

11 Answers

I found that the user control must have a parameterless constructor or it won't show up in the list. at least that was true in vs2005.

Using VS 2010:

Let's say you have a Windows.Forms project. You add a UserControl (say MyControl) to the project, and design it all up. Now you want to add it to your toolbox.

As soon as the project is successfully built once, it will appear in your Framework Components. Right click the Toolbox to get the context menu, select "Choose Items...", and browse to the name of your control (MyControl) under the ".NET Framework Components" tab.

Advantage over using dlls: you can edit the controls in the same project as your form, and the form will build with the new controls. However, the control will only be avilable to this project.

Note: If the control has build errors, resolve them before moving on to the containing forms, or the designer has a heart attack.

I just had this issue with VS 2022. There may be a quick/easy answer.

My quick and dirty user control would not appear in the toolbox (full rebuild etc.).

I quit the solutiuon and VS, reloaded all, rebuilt and it appeared and worked.

Related