Designer of nested objects question.

  • Thread starter Thread starter Iulian Ionescu
  • Start date Start date
I

Iulian Ionescu

I have a class (A) that has a member of another type (B).
Type B appears in the PropertyGrid at design time as an
expandable object so it's properties can be changed.
However, at design time I only want to show a certain
number of properties not all. For instance, assume that B
is the Button type and I only want to show the Font and
the BackColor property for it. How can I do that? I tried
to create a separate designer for a derived class and use
PreFilterProperties to remove all those that I don't need
but it doesn't look like this designer is ever loaded. It
looks like the designer of the main designed object (of
type A) takes care of everything... So, is there a way?

thank you!!
 
Whoa... Like 3 minutes after I posted this, I solved it...

The answer was to define a custom Attribute and apply it
to those properties I want to show only and then do this:

public override PropertyDescriptorCollection GetProperties
(ITypeDescriptorContext context, object value, Attribute
[] attributes)
{
return base.GetProperties (context, value, new Attribute
[] {new SpecialAttr()});
}
public override bool GetPropertiesSupported
(ITypeDescriptorContext context)
{
return true;
}

:-)
 
Back
Top