Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User Control Property Designer Properties

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

like image 250
Adam Haile Avatar asked Aug 12 '08 11:08

Adam Haile


People also ask

What is property in user control?

User Control properties are used to set the values of a User Control from the parent page.

What are the properties of controls?

These include properties such as Font, ForeColor, BackColor, Bounds, ClientRectangle, DisplayRectangle, Enabled, Focused, Height, Width, Visible, AutoSize, and many others.

Which property control the name of the controls?

Every control has it's properties one of the common properties of controls is name property. Name property is the one by which the control is identified and it is referred as the object name of that control.


2 Answers

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.

like image 69
John Avatar answered Sep 28 '22 21:09

John


Is this of use to you? I am not into CF development, but it looks like you need to add some XML metadata to enable it:

http://blogs.msdn.com/bluecollar/archive/2007/02/08/adding-compact-framework-design-time-attributes-or-more-fun-with-textboxes.aspx

Interesting read.. Looks like a lot of design time support was stripped out of CF because you dont design them on the devices.. Which seems kinda weird to me.. Cant imagine using a handheld as a development rig!

Scroll down about half way for the good stuff ;)

like image 27
Rob Cooper Avatar answered Sep 28 '22 22:09

Rob Cooper