This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have a winforms application, in any particular form we create uow when we open the form, and dispose it when we close the form. In the form we have a bindinglist On clicking and entry in the tree we use a single entity which is set as the datasource of a bindingsource. All the controls on the form are bound to the binding source. This works well for new records, edits, and deletes. The problem I have is if a field is changed, and I select a different value in the tree, before changing the entity attched to the bindingsource we confirm if we should save the changes or not. If we select save, all is good. However if I select cancel, I cannot seem to get rid of the Modified status on the entity. I have tried using CancelEdit on the bindingsource, also the CancelEdit on the entity, I have even tried to reload the bindinglist, but nothing works, it seems the only way I can get back is to dispose the uow, make a new one, and reload the bindinglist. This seems a lot of work just revert a single entity back to its previous values. I am sure there but be an easier way to do this, I am hoping someone can tell me. Many thanks. |
|
|
CancelEdit should reset the entity data and entity state to what it was when you called BeginEdit -- i.e. if an entity was in Default state when you called BeginEdit, and you make changes, and then do a CancelEdit, it should go back to Default state. Are you seeing the entity values revert but it stays in Modified state? Or the entity values don't revert at all? If the latter, are you calling BeginEdit? Or is the binding source meant to call it for you? If so, is it doing so? (You can override BeginEdit and set a breakpoint to check.) Can you provide a minimal repro (a single small entity and a single screen)? |
|
|
Hi Ivan, Thanks for the prompt reply. Based on your comments I went back to do some investigating, and Ifound the problem was, that the Begin Edit was not being used, eitehr directly by the code, or indirectly by the BindingSource. So I added a call to that method in the Activate code, and now all seems to work well. Again, many thanks for the help. Best regards Mark |
|