While going through PTtracker, i noticed that cancel button doesn't get disabled even when there is nothing to Undo.
Currently i'm using IsDirty Property to change status of cancel button on my forms when CurrentItemChange occurs (Same like save button)..
is this the right way or am i missing some property which exposes whether Undo is available on object or not...
That should be correct.
However, there is a protected EditLevel value available, so I suppose you could use that to create a public IsUndoable property or something. If EditLevel is greater than 0 then undo is technically possible, even if the object hasn't been changed.
Or you could combine the two: returning true only if IsDirty is true and EditLevel is >0.
Thanks for your help.. can this property also be added like other properties (IsDirty, Issavable etc.) as this can be useful.
I have one more issue, in cancel button click event i'm calling CancelEdit which is undoing all the changes, so if i have changed 3 fields it is changing all the 3 fields.
I have added a BeginEdit call in CurrentItemChanged, hoping that this will give me field wise undo capability but that is not happenning.
Infact after beginedit call, canceledit is not undoing any changes...
can you pls help in that..
If you are using a bindingsource control, which I recommend,
then you should NOT call BeginEdit, CancelEdit or ApplyEdit directly on your
object at all. Instead, you should call CancelEdit and EndEdit on the
bindingsource (you don’t need to call BeginEdit at all – that’s
automatic).
Rocky
Copyright (c) Marimer LLC