This project has moved and is read-only. For the latest updates, please go here.

PropertyGrid Categorization with Access Modifiers

Feb 11, 2014 at 3:13 PM
I'm trying to hook up a Propertygrid to a class that I have. I've been trying to sort the properties by category by decorating them with with the Category attribute. However, I've found that those settings are not taking effect on properties that are set as Internal. Changing those properties to public does apply the proper category.

Is this intentional? Is there something I am missing?
Feb 12, 2014 at 3:12 PM

From a small sample project where the PropertyGrid.SelectedObject = MyClass, I can see that only the public properties are displayed in the propertyGrid. Here's the reason : in "ObjectContainerHelperBase.GetPropertyDescriptors" method, this line is used :
descriptors = TypeDescriptor.GetProperties( instance.GetType() );
The instance type is the MyClass type and this system method returns only the public properties into the descriptors.
Feb 12, 2014 at 4:50 PM
Hi, thanks for the follow up.

Could an option be added to control that restriction? In my own reflection, I've been using:

.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
Feb 13, 2014 at 8:17 PM