Detecting Column Data Change without Leaving Row

J

Jerry

I have a WinForms application that has a master DataSet with related
DataTables that various forms reference and bind to. I need to detect when
changes are made to the DataSet by a particular form so that the user can
choose to cancel or apply thoses changes (the Apply button is only enabled
after a change is detected, e.g. after they alter a value and then tab out
of the control). So I'm interesting in detecting changes made only to the
DataRows that that form's controls bind to for a specific BindingContext.
I've got it mostly working with one remaining issue. When there are multiple
controls on a form that reference the same DataRow, I have not been able to
detect a change to the row (e.g. when the user tabs to the next field)
unless the control gaining focus does not reference the same DataRow as the
control losing focus.

What I've learned from my experimenting with it is that the RowState is not
updated until I use EndEdit for the row. However, this only works after the
"row loses focus." As long as the next control still binds to the same
DataRow the DataRowVersion.Proposed doesn't exist and the EndEdit doesn't do
any good.

Please advise.
 
J

Jerry

Problem solved. I was checking for changes on the control Leave event. I
changed it to the Validated event and it now performs as desire with one
exception. If I make a change and then go back and change it back to its
original value, the RowState still shows Modified. Is there a way to have it
automatically go back to Unchanged. I guess I could step through all the
columns and test the current version with the original version and if they
are the same do an AcceptChanges on that row. It seems that there should be
a better way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top