edit level mismatch in UndoChanges issue (parent/child)

edit level mismatch in UndoChanges issue (parent/child)

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


cptcrash80 posted on Thursday, January 28, 2010

I'm currently having a problem getting the n-level undo working properly on one of our windows forms. We have a business object that is set up in the following manner:

<Item> (inherits Csla.BuisnessBase)
    <DrillItemCollection> (inherits Csla.BusinessListBase)
        <DrillItem> (inherits Csla.BusinessBase, uses MarkAsChild())

Our initial edit form takes an instance of the Item object. When the form is loaded we set up some simple databinding for some text values on the object, mapping the properties to a couple textboxes. We do not however use databinding for the child collection. It is just assigned to a listbox as the data source. Our secondary edit form takes an instance of DrillItem. The 2 properties of DrillItem are databound to a couple textboxes. NOTE: We are not using a Csla bindingSource, we are doing our databinding in the following fashion:

textBoxLabel.DataBindings.Add(new Binding("Text", PluginModel, "Label") { DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged });

The creation methods look similar to this:

private Item _item;
public InitialForm(Item item)
{
_item = item;
_item.BeginEdit();
}

void okButtonClick(object sender, EventArgs e)
{
_item.ApplyEdit();
}

void cancelButtonClick(object sender, EventArgs e)
{
_item.CancelEdit();
}

and the secondary form:

private DrillItem _drill;
public SecondForm(DrillItem drill)
{
_drill = drill;
_drill.BeginEdit();
}

void okButtonClick(object sender, EventArgs e)
{
_drill.ApplyEdit();
}

void cancelButtonClick(object sender, EventArgs e)
{
_drill.CancelEdit();
}

I have tried the following configurations:

The issue that I'm running into is any time the cancel button is used on the InitialForm after a DrillItem has been modified and the changes have been accepted a "edit level mismatch in UndoChanges" error is thrown. Am I implementing the edit functions properly, or is there something else that needs to be done?

Copyright (c) Marimer LLC