开发者

UITypeEditor and readonly reference type properties in .Net, WinForms

开发者 https://www.devze.com 2022-12-20 22:31 出处:网络
I thought I had type editors and converters naile开发者_如何学God until I tried to persist a Readonly Reference type property after editing it in a UITypeEditor.

I thought I had type editors and converters naile开发者_如何学God until I tried to persist a Readonly Reference type property after editing it in a UITypeEditor.

In my UITypeEditor, because I'm working with a read only property, I'm careful to pass back the original value (after updating the relevant sub property).

This change is reflected immediately on the designer but will not be persisted unless I do something like resize the control that the property is attached to.

To fix this I, blindly, include a call to context.OnComponentChanged() before returning the value.

I can see why this is needed. It's a reference type, I've altered it (not replaced it), and the property grid doesn't know this. I have a couple of questions for clarification:

Do I need a call to context.OnComponentChanging as well? A simple call to OnComponentChanged works in the tests I've done so far, but I don't want biting on the arse at some point in the future.

Also, is there any danger that, with my call to OnComponentChanging, I'll be persisting other components, in DesignerTransactions, that I shouldn't be persisting?

0

精彩评论

暂无评论...
验证码 换一张
取 消