4

I'm using the PropertyGrid (in the CollectionEditor) to edit some properties of a class. The properties are actually wrapped in classes that implement ICustomTypeDescriptor. One of them uses a custom editor that inherits from UITypeEditor. When the user changes the value of this property in the custom editor, the value of another property is also being updated (by code in the custom editor; the property wrapper has a reference to the other property for this reason). So far so good.

But when the user closes the custom editor, the PropertyGrid only shows the new value of the edited property and does not refresh the other property (even though its value has definitely changed).

How can I refresh the entire containing PropertyGrid from the custom editor?

Ian R. O'Brien
  • 6,682
  • 9
  • 45
  • 73
Peladao
  • 4,036
  • 1
  • 23
  • 43
  • Use the [RefreshProperties] attribute on the property you edit. – Hans Passant Dec 15 '12 at 17:57
  • @HansPassant It doesn't work. I've tried on all properties and also returning this through the PropertyDescriptor inheritor. Perhaps this is because the PropertyGrid I'm using is actually the one inside the CollectionEditor? – Peladao Dec 15 '12 at 20:40
  • Somebody broke my crystal ball this morning, I'll be out of one for the rest of the year. Clearly you'll need to do a much better job documenting your question. – Hans Passant Dec 15 '12 at 20:50

1 Answers1

2

I found the solution myself:

The EditValue method of the custom editor should return a new object, not the passed in value object. Then the PropertyGrid automatically refreshes the other properties as well.

I did not need to use the RefreshProperties attribute anywhere.

Peladao
  • 4,036
  • 1
  • 23
  • 43