I am using the property grid in winforms to display the properties on my custom type - I did this using a custom type descriptor (implementing interface ICustomTypeDescriptor) so that the public properties of my object are displayed, each with their own PropertyDescriptor implementation.
The implementation is close to the code described here: http://www.codeproject.com/Articles/4448/Customized-display-of-collection-data-in-a-Propert
This works as in I can see all the properties and they have their own editors in the property grid however I have the problem on how to implement
public override void ResetValue(object component)
On the base PropertyDescriptor.
At the moment I have implemented it like this:
public override void ResetValue(object component)
{
if (!_isReadOnly && _dataDefault != null)
{
SetValue(component, _dataDefault.Value);
}
}
However, althogh the data does indeed get updated the property grid display just show the old value unless I refresh it - I can't figure out how the property grid would update or get to know a value has changed, is there some sort of event that refreshes that cell that can be triggered from a PropertyDescriptor implementation?
I found a similar question here: PropertyGrid doesn't notice properties changed in code?
The solution I went with was to implement the INotifyPropertyChanged notification events and register it on the property grid to refresh.