Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grouping my custom control properties separately in designer grid

I am working with User Controls. I have created my own control properties. Now I want to group my own properties separately in designer grid.

How to achieve that?

Regards

like image 762
Shahzad Avatar asked Jul 12 '11 13:07

Shahzad


1 Answers

Look, here is your answer. In other words, use Category attribute on a property.

Also, here is a link to a useful article (Custom Design-time Control Features in Visual Studio .NET). The article is rather old (2003.), but I couldn't find anything official that is more recent. Also, I don't know if you need any other specific feature, but I guess it should be a good place to start.

I've tried this and it works for me:

public partial class UserControl1 : UserControl
{
    public UserControl1()
    {
        InitializeComponent();
    }

    [Category("MyOwn")]
    public String MyProperty { get; set; }
}

Example1

Note, however, that you can't see your properties when a designer of your user control is open. The custom properties will be visible in designer's property grid only when your user control is a part of another form/control and is selected. While designing your control, you have no designer access to such properties. Look at my picture above. The form contains a user control and then a user control is selected. Then the property is visible on the property grid.

Also, make sure the Categorized is selected in PropertyGrid: Categorized view

like image 81
Kornelije Petak Avatar answered Nov 13 '22 21:11

Kornelije Petak