Designer of nested objects question.

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!!
 
I

Iulian Ionescu

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;
}

:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top