This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Many of our properties have a private set accessor that allows them to be set in the constructor but otherwise prevents modification later. Since users should not be trying to modify them, we want to filter the PropertyGrid to hide read-only properties -- i.e., those with no set accessor at all -- as well as those with a private set accessor. The Node class and the Node's Property property both have CanWrite properties which do the standard thing -- return false if there is no set accessor (but true if there is any set accessor, whether public or private). So that's only partially helpful. I can get the PropertyInfo from the Node class (or AsPropertyInfo on the Node's Property property). Calling its GetSetMethod() method should return null if the set accessor is private. However, GetSetMethod() throws a not implemented exception when called, so it's no help either. So how can I filter out read-only properties and those that have private set accessors? BillBR |
|
|
Hello BillBR The common way of doing this is to use the Browsable attribute which our PropertyGrid happens to support. For all the properties that you do not want to be displayed at all in the PropertyGrid, you can set the Browsable attribute. For example:
Jason Fauchelle |
|
|
Thanks for the reply, Jason. Unfortunately, we're using a loosely coupled architecture, so we're not able to add the BrowsableAttribute to all the properties we might encounter. Do you have any other suggestions about how to detect the private set accessor through the PropertyGrid nodes? BillBR |
|
|
I'll look at adding an option to ignore read-only properties soon. Jason Fauchelle |
|
|
Hello BillBR The next nightly build will include a CanDisplayReadOnlyProperties property on the PropertyGrid. Setting this to false will hide all read only properties including private/internal properties and properties with no setters. Jason Fauchelle |
|
|
You folks are great. The new CanDisplayReadOnlyProperties property works like a charm! Thanks so much, BillBR |
|