简体   繁体   English

如何将自定义Windows窗体控件添加到Visual Studio工具箱

[英]How to add a Custom Windows Forms Control into Visual Studio Toolbox

I want to add my custom control into the VS Toolbox. 我想将自定义控件添加到VS Toolbox中。 But I need it to appear in toolbox always when a new project is open. 但是我需要它在新项目打开时始终出现在工具箱中。 How can I do that? 我怎样才能做到这一点?

Create a VSIX package to install the control 创建一个VSIX包以安装控件

You can create a VSIX package to distribute and install user controls to toolbox. 您可以创建VSIX包,以将用户控件分发并安装到工具箱。

To do so, you can create a VSIX Project and add a Windows Forms ToolBox Control to the project. 为此,您可以创建一个VSIX项目并将Windows窗体工具箱控件添加到该项目。 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属性,该属性确定该控件将出现在其中的选项卡。您可以将现有或新的选项卡名称传递给该属性:

[ProvideToolboxControl("Some Tab Name", false)]
public partial class ToolboxControl1 : UserControl

You can also fill the information in .vsixmanifest file. 您也可以在.vsixmanifest文件中填写信息。 Then when you build the project, it creates a .vsix package file in \\bin\\debug folder of the project which you can distribute this file. 然后,在构建项目时,它将在项目的\\bin\\debug文件夹中创建一个.vsix软件包文件,您可以分发该文件。 If you run the file, it installs the control in visual studio toolbox. 如果运行该文件,它将在Visual Studio工具箱中安装该控件。

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. VS 2013在新项目窗口的可扩展性组下有一个Windows窗体工具箱控件项目模板,您可以使用它来创建项目。 Starting from VS 2015 you should use VSIX Project template. 从VS 2015开始,您应该使用VSIX Project模板。

Manually Add Control to Toolbox 手动将控件添加到工具箱

You can copy the dll of your control to a permanent location. 您可以将控件的dll复制到永久位置。 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. 然后右键单击“工具箱”,例如在“常规”选项卡上,然后单击Choose Items ...然后在.Net Framework Components选项卡的“选择工具箱项”窗口中,单击“ Browse...按钮,然后打开控件的dll。 Then in the components list, check the control and click OK button. 然后在组件列表中,检查控件,然后单击“ OK按钮。 The control will appear under the selected tab. 该控件将出现在所选选项卡下。 You also can add your own tab simply by right click and choose Add Tab . 您还可以通过右键单击并选择Add Tab来添加您自己的标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Visual Studio 2015中创建自定义控件并将其添加到工具箱 - how to create custom control in visual studio 2015 and add it to toolbox 如何在Visual Studio工具箱中添加图形控件 - How do I add the graph control in the Visual Studio toolbox Visual Studio 未将自定义用户控件添加到工具箱 - Visual Studio not addin custom user control to toolbox 如何将自定义控件添加到工具箱? - How to add a custom control to the toolbox? Visual Studio 2012(x64)-Windows Phone工具包-如何在VS中的工具箱中添加WP工具箱自定义控件 - Visual Studio 2012 (x64) - Windows Phone Toolkit - How to Add WP toolkit custom controls to toolbox in VS 无法将QuickTime控件添加到Visual Studio中的Windows窗体项目 - Unable to add QuickTime control to Windows Forms project in Visual Studio 如何将ToolStripSplitButton添加到Visual Studio Toolbox? - How to add ToolStripSplitButton to Visual Studio Toolbox? Visual Studio 2019 - 无法将自定义管道 Object 添加到工具箱 SSIS - Visual Studio 2019 - Cannot add Custom Pipeline Object to Toolbox SSIS 无法在 Visual Studio Forms 中添加浏览器控件 - Unable to add browser control in Visual Studio Forms 如何在Visual Studio 2010中添加System.Windows.Forms - how to add System.Windows.Forms in visual studio 2010
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM