[英]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: 注意:
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.