自定义控制与工具箱选项卡

发布于 2024-12-24 19:18:20 字数 649 浏览 3 评论 0原文

我正在创建一个用户界面,并试图找出组织所有自定义控件的最佳方法。

我已经知道我可以执行以下操作:

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
{
}

我想做的最后一件事是指定我的自定义控件在工具箱窗口中出现的选项卡(即类别) - 有人有任何建议吗?还有其他处理自定义控件的技巧吗?

提前致谢! 威廉

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) 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) 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?

Thanks in advance!
William

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南笙 2024-12-31 19:18:20

请查看MSDN 演练:自动加载工具箱项目

从上面:

将自定义控件添加到工具箱的推荐方法是使用
Visual Studio 10 SDK 附带的工具箱控件模板,
其中包括自动加载支持。该主题保留用于
向后兼容性,用于将现有控件添加到工具箱,
以及高级工具箱开发。

查看上面演练提到的 Window Forms Toolbox Control

[ProvideToolboxControl("General", false)]
public partial class Counter : UserControl

Take a look at this MSDN Walkthrough:Autoloading Toolbox Items.

From above:

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.

Looking at the Window Forms Toolbox Control that above walkthrough mentions:

[ProvideToolboxControl("General", false)]
public partial class Counter : UserControl
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文