Disabling update of a grid while editing

Disabling update of a grid while editing

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


cds posted on Friday, October 27, 2006

Hi Guys

Some wisdom please...

I have a sitatuion where I have an Editable Root with an Editable Child collection haning off it. I have UI design where I am displaying the children collection in a DataGridView - as a read only view of the collection. I have typical Add/Edit buttons where the user can select a child object, click the Edit button then go to a modal dialog to edit it, or click the Add button and add a new object.

My code on Add is basically something like:

ero.BeginEdit();

ChildClass child = ero.Children.AddNew();

ChildPropertiesForm form = new ChildPropertiesForm(child);

if (form.ShowDialog() == DialogResult.OK)

   ero.ApplyEdit();

else

   ero.CancelEdit();

 

All works fine.

However, my bugbear is that I'm present a modal dialog to the user and the user's expectation is that the changes they're making won't happen until they click OK. But, as they're changing fields on the modal dialog form they can see the changing happening in the DataGridView sitting behind in on the parent form.

Is there any easy way to prevent this from happening? I know that what is happening underneath is just being shown in the bound DataGridView but it seems a little weird from the user's perspective. I've tried doing things like calling SuspendBinding, but it has no effect (though I wouldn't yet claim to be an expert a data binding).

Any guidance much appreciated.

Thanks,

Craig

P.S. CSLA 2.1

 

Brian Criswell replied on Saturday, October 28, 2006

I think this in an opportunity to educate the user that their changes will be accepted if the click OK and rolled back if they click cancel, rather than their changes are "made" when they click OK.  However, if it is really important, you could try suspending the list changed events on the BindingSource.  If that does not work, you could clone the item you are editing, let the user edit it, and use the DataMapper to put the values back into the original object if they click OK.

cds replied on Saturday, October 28, 2006

Thanks Brian

Disabling the list changed events worked fine for me.

Craig

Copyright (c) Marimer LLC