自定义控件工具箱选项卡 [英] Custom Control & Toolbox Tab
问题描述
我正在创建一个用户界面,并试图找出组织所有自定义控件的最佳方式.
I am creating a user interface and I am trying to figure out the best way to organize all of my custom controls.
我已经知道我可以执行以下操作:
I already know that I can do the following:
1) 如果我想通过属性"窗口为设计时操作显示一个属性,我使用以下...
1) If I want to have a property visible for design-time manipulation via the Properties window, I use the following...
[Browsable(true)]
[Description("Text for Display"), Category("Custom Properties")]
public string DisplayText
{
get
{
return textDisplay.DisplayText;
}
set
{
textDisplay.DisplayText = value;
}
}
2) 如果我想从工具箱窗口隐藏控件,我可以使用以下...
2) If I want to hide the control from the Toolbox window, I can use the following...
[ToolboxItem(false)]
public class TStrategyInput : FlickerControl
{
}
我要做的最后一件事是指定我的自定义控件出现在工具箱"窗口中的选项卡(即类别) - 有没有人有任何建议?还有其他处理自定义控件的技巧吗?
The final thing that I am trying to do is to specify the Tab (i.e. category) that my custom control comes up under in the Toolbox window - does anyone have any suggestions? Are there any other tricks out there for handling custom controls?
提前致谢!威廉
推荐答案
看看这个 MSDN 演练:自动加载工具箱项.
从上面:
向工具箱添加自定义控件的推荐方法是使用Visual Studio 10 SDK 附带的工具箱控件模板,其中包括自动加载支持.此主题保留用于向后兼容性,用于将现有控件添加到工具箱,以及高级工具箱开发.
The recommended way to add custom controls to the Toolbox is to use the Toolbox Control templates that come with the Visual Studio 10 SDK, which include auto-loading support. This topic is retained for backward compatibility, for adding existing controls to the Toolbox, and for advanced Toolbox development.
查看上述演练提到的 Window Forms Toolbox Control:
Looking at the Window Forms Toolbox Control that above walkthrough mentions:
[ProvideToolboxControl("General", false)]
public partial class Counter : UserControl
这篇关于自定义控件工具箱选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!