Global Cancel

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

I want to create a single Cancel method to cancel all changes made to any
fields in a UserControl. I have a method that creates a Binding object, adds
it to a collection and than adds the Binding to the control.

textBox1.DataBindings.Add(CreateDataBinding("Text", myobject, "Caption") );

public void Cancel()
{
foreach (Binding b in this.Bindings)
b.BindingManagerBase.CancelCurrentEdit(); // This never changes the
value back
}

Is there anyway to create something like I want?

Thanks,
Joe
 
The object you are binding to has to support being able to undo changes.
This does not come for free.

Your object has to implement the IEditableObject interface, I suggest you
look at that.
 
Back
Top