Create a VSIX package to install the control
You can create a VSIX package to distribute and install user controls to toolbox.
To do so, you can create a VSIX Project and add a Windows Forms ToolBox Control to the project. The control is decorated with a ProvideToolboxControl
attribute which determines the tab that the control will appear in. You can pass an existing or a new tab name to the attribute:
[ProvideToolboxControl("Some Tab Name", false)]
public partial class ToolboxControl1 : UserControl
You can also fill the information in .vsixmanifest
file. Then when you build the project, it creates a .vsix
package file in indebug
folder of the project which you can distribute this file. If you run the file, it installs the control in visual studio toolbox.
More information:
Note:
- VS 2013 has a Windows Forms ToolBox Control Project Template under extensibility group of new project window and you can use it to create the project. Starting from VS 2015 you should use VSIX Project template.
Manually Add Control to Toolbox
You can copy the dll of your control to a permanent location. Then right click on ToolBox, for example on general tab, then click Choose Items ...
then in Choose Toolbox Items window in .Net Framework Components
Tab, click Browse...
button and open the dll of your control. Then in the components list, check the control and click OK
button. The control will appear under the selected tab. You also can add your own tab simply by right click and choose Add Tab
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…