C# 在工具箱中包含派生控件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C# Include Derived Control in Toolbox
提问by Robin Robinson
This is in reference to my other question Auto Clearing Textbox.
If I choose to derive a new TextBox control from TextBox instead of implement a user control just containing my Textbox, how would I include that in the toolbox.
这是参考我的另一个问题Auto Clearing Textbox。
如果我选择从 TextBox 派生一个新的 TextBox 控件而不是实现仅包含我的 Textbox 的用户控件,我将如何将其包含在工具箱中。
采纳答案by Adam Haile
Right-click the toolbox, click "Choose Items" from the context menu, browse to your DLL, and select it.
右键单击工具箱,从上下文菜单中单击“选择项目”,浏览到您的 DLL,然后选择它。
To extend on Greg's answer... Just to clarify, you cannot add a user control to the tool box if the code for it is in the same project that you want to use it in. For some reason MS has never added this ability, which would make sense since we don't want to always have to create a User Control Library DLL everytime we want to use a user control. So, to get it in your tool box, you have to first create a separate "User Control Library" project (which canbe in the same solution!) and then do what Greg said.
扩展 Greg 的答案......只是为了澄清,如果它的代码在你想要使用它的同一个项目中,你不能将用户控件添加到工具箱中。出于某种原因,MS 从未添加过此功能,这是有道理的,因为我们不希望每次要使用用户控件时都必须创建用户控件库 DLL。因此,要将它放入您的工具箱中,您必须首先创建一个单独的“用户控件库”项目(可以在同一个解决方案中!),然后按照 Greg 所说的去做。
回答by Greg Hurlman
Right-click the toolbox, click "Choose Items" from the context menu, browse to your DLL, and select it.
右键单击工具箱,从上下文菜单中单击“选择项目”,浏览到您的 DLL,然后选择它。