我正在创建一个用户界面,我正在尝试找出组织所有自定义控件的最佳方式。
我已经知道我可以做到以下几点:
1) 如果我想通过“属性”窗口使设计时操作可见的属性,我使用以下...
[Browsable(true)]
[Description("Text for Display"), Category("Custom Properties")]
public string DisplayText
{
get
{
return textDisplay.DisplayText;
}
set
{
textDisplay.DisplayText = value;
}
}
2) 如果我想在工具箱窗口中隐藏控件,我可以使用以下...
[ToolboxItem(false)]
public class TStrategyInput : FlickerControl
{
}
我要做的最后一件事是指定我的自定义控件出现在“工具箱”窗口中的选项卡(即类别)——有人有什么建议吗?还有其他处理自定义控件的技巧吗?
提前致谢! 威廉
最佳答案
看看这个MSDN Walkthrough:Autoloading Toolbox Items .
从上面看:
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上面的演练提到:
[ProvideToolboxControl("General", false)]
public partial class Counter : UserControl
关于c# - 自定义控件和工具箱选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8736004/