PropertyGrid questions
-
Hi all, this
PropertyGrid
is a great tool but I'm having difficulty really getting my head around its workings. I've figured out how to make a class PropertyGrid-ready and how to define default values for various properties. What I would like to do now is to iterate through all the properties in the grid (ie all the properties of theSelectedObject
) and write the value to a file if it differs from the default value for that property. In other words, there are two things that I'm not sure how to do. First of all, how do I iterate through all of the properties in aPropertyGrid
? Obviously the properties will differ depending on the type of theSelectedObject
. Secondly, how do I determine if the value of a given property differs from the default value for that property, in other words the value of theDefaultValueAttribute
for that property? Thanks in advance. -
Hi all, this
PropertyGrid
is a great tool but I'm having difficulty really getting my head around its workings. I've figured out how to make a class PropertyGrid-ready and how to define default values for various properties. What I would like to do now is to iterate through all the properties in the grid (ie all the properties of theSelectedObject
) and write the value to a file if it differs from the default value for that property. In other words, there are two things that I'm not sure how to do. First of all, how do I iterate through all of the properties in aPropertyGrid
? Obviously the properties will differ depending on the type of theSelectedObject
. Secondly, how do I determine if the value of a given property differs from the default value for that property, in other words the value of theDefaultValueAttribute
for that property? Thanks in advance.Hi, The MS PropertyGrid has not been designed to do that but you can still call the SelectedGridItem property to get the selected property, and then Parent property of the returned GridItem until GridItemType equals Root. Then, you can recursively parse the grid with the GridItems property of the GridItem class. After that, the Value and PropertyDescriptor properties will help you compare the actual value with the default one. I hope this helps. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker