Custom Control & Toolbox Tab

放肆的年华 提交于 2020-01-04 03:12:19

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/8736004/custom-control-toolbox-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!