control property categoryattribute

  • Thread starter Thread starter Lee Crowe
  • Start date Start date
L

Lee Crowe

Hi

I am in the middle of creating a control and wondered if someone could
help me with a problem I have.

My control is based on an existing control but I have added at least
twenty properties to this control and would like to put them in a
seperate section in the property window.

The code below puts the TableCssClass property under the "Custom
Properties" category as expected.

[
Browsable(true),
Description("css class for table to use in presentation mode."),
Category("Custom Properties"),
DefaultValue("")
]
public string TableCssClass
{
get { return _tableClass; }
set { _tableClass = value; }
}


But say for example I wanted to put the TableCssClass property into a
category named "Style" under the category named "Custom Properties".

How would I do this I'm sure it is possible because in the
"Appearance" category you see "Font" which expands to get at size
properties e.t.c.

HAS ANYBODY GOT ANY IDEAS

Thanks in advance

Lee Crowe
 
Hi,

It is indeed possible to do this.

What you need to do is create a custom control class within your
control project containing all the sub-properties you want, eg.
CustomProperties.

Then add one property to your "main" control of type CustomProperties
(what you name this property will be the heading of the expandable
list) under the "Style" category. This property just needs the get part
of the property, simply returning the internal "CustomProperties"
object.

Now when you add your control you will have a property under "Style"
called "CustomProperties", which will expand revealing all the
properties of the "CustomProperties" class.

Hope this makes sense!
Regards,

Peter Chadwick (MCP)
(e-mail address removed)
 
I should probably mention that this will get your properties displaying
as desired. You will need to play around with persistence properties in
order to get all the cascading properties saving properly.

If you do a search on saving objects as properties there should be
stuff out there (I have done the same myself before, just can't
remember off the top of my head the persistence settings).
Peter Chadwick (MCP)
(e-mail address removed)
 
Back
Top