Hi All,
I have a form containing only a PropertyGrid that I use to modify an
instance of the following class:
class MyClass
{
Point _point = new Point();
[CategoryAttribute("Drawing")]
public Point MyPoint
{
get { return _point; }
set { _point = value; }
}
}
All works fine.
Now if I add
this._propertyGrid.BrowsableAttributes
= new AttributeCollection(
new Attribute[] { new CategoryAttribute("Drawing") });
to the form's initialization code: what happens is that "MyPoint"
property does not more expand in the PropertyGrid.
Is there a way to apply the CategoryAttribute only to the first level of
properties?
TIA.
Marco.
VisualHint - 12 Oct 2007 15:44 GMT
Hello Marco,
I guess that you are trying to show only properties (and their
subproperties) that are under a particular category. Unfortunately you
are not using the right tool to do that. Your subproperties get
filtered because they don't have the CategoryAttribute you supply. A
better way would be to use a TypeDescriptor or TypeConverter for your
class that would filter out any toplevel property that is not under
the category (it would publish only the PropertyDescriptors that have
the CategoryAttribute).
Best regards,
Nicolas Cadilhac @ VisualHint (http://www.visualhint.com)
Home of Smart FieldPackEditor.Net / DateTimePicker replacement (http://
www.visualhint.com/index.php/fieldpackeditor)
Home of Smart PropertyGrid for .Net and MFC (http://www.visualhint.com/
index.php/propertygrid)
Microsoft PropertyGrid Resource List - http://www.propertygridresourcelist.com
> Hi All,
>
[quoted text clipped - 29 lines]
> TIA.
> Marco.
Nicholas Paldino [.NET/C# MVP] - 12 Oct 2007 18:08 GMT
Marco,
Unfortunately, no. You would have to apply the appropriate attributes
to your parent class (which I can see you not wanting to do, for obvious
reasons).

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Hi All,
>
[quoted text clipped - 29 lines]
> TIA.
> Marco.