parent.CancelEdit() does NOT remove all newly added children

parent.CancelEdit() does NOT remove all newly added children

Old forum URL: forums.lhotka.net/forums/t/11185.aspx


fredg posted on Wednesday, February 22, 2012

Hi, I'm working on Windows Form. I added 2 child objects on UI and then cancel. The issue is one child is removed but another one still exists in the parent's children collection.

JonnyBee replied on Wednesday, February 22, 2012

Is the object still active in databinding or unboud from the UI when you call CancelEdit?

If the object is still databound then this is the expected behavior.

The object must be unbound before you can call CancelEdit and expect a revert to the BeginEdit snapshot (taken before bound).

RockfordLhotka replied on Wednesday, February 22, 2012

To add to this, you should never interact with the object while bound. If the object is bound, you should only interact with the binding source.

Copyright (c) Marimer LLC