User Control Property Designer Properties

Adam Haile picture Adam Haile · Aug 12, 2008 · Viewed 14.6k times · Source

For a C# UserControl on Windows Mobile (though please answer if you know it for full Windows...it might work) how do you change what shows up in the Designer Properties window for one of the Control's public Properties. For example:

private Color blah = Color.Black;

public Color Blah
{
    get { return this.blah; }
    set { this.blah = value; }
}

This shows up for the control, but it's in the "Misc" category and has no description or default value. I've tried using the settings in System.ComponentModel like "DesignerCategory", such as:

[DesignerCategory("Custom")]

But says this is only valid for class declarations... could've sworn it was the System.ComponentModel items I used before...

Update:

@John said:

DesignerCatogy is used to say if the class is a form, component etc.

Try this:

[Category("Custom")]

Is there a particular namespace I need to use in order to get those? I've tried those exactly and the compiler doesn't recognize them.

In .NETCF all I seem to have available from System.ComponentModel is:

DataObject,
DataObjectMethod,
DefaultValue,
DesignerCategory,
DesignTimeVisible,
EditorBrowsable

The only one it doesn't scream at is EditorBrowsable

Answer

John picture John · Aug 12, 2008

DesignerCategory is used to say if the class is a form, component etc.

For full windows the attribute you want is:

[System.ComponentModel.Category("Custom")]

and for the description you can use [System.ComponentModel.Description("This is the description")]

To use both together:

[System.ComponentModel.Category("Custom"),System.ComponentModel.Description("This is the description")]

However this is part of system.dll which may be different for windows mobile.