[Resolved] [2.0] Hide inherited members in PropertyGrid
I'm working on a user control for a project of mine, and I would like to save a lot of time and effort by letting the user edit the properties of another user control via the PropertyGrid. However, I'd like to just show the members that I have created, not the ones inherited from Control. Is there an easy way to accomplish this? I looked at the AttributeCollection (or whatever), but it did not seem to contain the information I wanted.
Re: [2.0] Hide inherited members in PropertyGrid
I have the same problem with my panel user control in vb.net. What was suggested was to create a filtering class inbetween the user control and any properties and collection properties etc.
Re: [2.0] Hide inherited members in PropertyGrid
You would create a corresponding pass-through member in your class and apply the Browsable attribute as false:
Code:
[Browsable(false)]
public new SomeType SomeProperty
{
get { return base.SomeProperty; }
set { base.Someproperty = value; }
}
Re: [2.0] Hide inherited members in PropertyGrid
Both these suggestions sound good. Someone else mentioned that I should implement ICustomTypeDescriptor and implement the GetProperties() / GetDefaultProperty() / GetEvents() / GetDefaultEvent() functions.
Re: [Resolved] [2.0] Hide inherited members in PropertyGrid
Its coming back to me now. I wanted to use a custom property that was the same name as a default built in one. so I had to create the intermediate filtering class. You could do like John posted with the Browseable (false) as its an easy solution and should be all you need.