LOGIN    REGISTER    YOUR CART

homepage
VisualHint's blog
Jan02

PropertyValueChanged for collections bug fix

I was not aware of this bug in the Microsoft PropertyGrid until a customer told me it was doing the same thing in Smart PropertyGrid. This is interesting enough to add a post here about it. The issue is that PropertyValueChanged is not fired for certain collections. It works with an array but doesn’t for a List<> for instance. The reason is that the UITypeEditor.EditValue(...) method returns the reference on the original collection even if its content has been modified. I looked in Reflector and after this method returns, the Microsoft code does a simple “if (obj1 != obj2) ...” which of course returns false and doesn’t trigger the event. My code was actually doing the same thing, so I fixed it to handle this particular case. This is another reason to purchase from a small company that reacts and makes a product that evolves fast. This enhancement is available in version 2.1 beta2 that is out today.