Sign in to follow this  
gellin

[.net] PropertyGrid Issues

Recommended Posts

Say I have a class, Class1 which contains as a property an instance of Class2. When I make Class1 the SelectedObject in the PropertyGrid, I am able to see each property contained in Class2 by expanding Class2. My problem is that I would like to take a couple of these properties contained in Class2 and display them on the top level in the PropertyGrid (so you don't have to expand Class2 every time to view them). Is there anyway to do this without creating a duplicate property inside of Class1 that sets/gets the matching property in Class2? I can provide some source code if I'm being unclear.

Share this post


Link to post
Share on other sites
I believe you could implement ICustomTypeDescriptor in Class1, and then in the GetProperties method, get the PropertyDescriptors from TypeDescriptor.GetProperties(this), and add onto them selected properties from TypeDescriptor.GetProperties(Class2 instance) and return the combination of those.

Personally I would just add the duplicate properties though.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this