开发者

PropertyGrid and Providing Undo

开发者 https://www.devze.com 2023-01-20 18:14 出处:网络
When using the PropertyGrid and passing in an Object for the user to make changes, what is the best approach for handling a cancel/undo.

When using the PropertyGrid and passing in an Object for the user to make changes, what is the best approach for handling a cancel/undo.

Do you provide a copy of 开发者_开发百科the original object into the property grid make your changes then if the user accepts the mods then update the values into the original object?

Make a copy of the original settings and pass in the live object and if they cancel, move back the original values?

Or some other approach?


Any and all can work; for simple objects, the approach I've used most commonly (in that scenario) is serialization to create a deep-clone without needing to maintain any code. If you need to undo, just deserialize the snapshot. However, this works best if the object you want to undo isn't already in 27 properties and collections scattered over the model; in that scenario you might have to do a lot more work.

0

精彩评论

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