SOLUTION: databinding dirty checking

E

Erik Frey

Hi,

Yesterday I asked the question "Is there a way to implement dirty
checking within the framework of windows forms databinding?" and learned
that I'd have to roll my own solution. I thought I'd share the code here in
case anyone using databinding has ever run across this same problem. Here's
a description of the class:

"DirtyChecker was created to overcome a problem with Winforms databinding.
Currently, the prescribed way to check if controls have become dirty (i.e.
their bound values differ from the underlying data source) is to call
EndCurrentEdit, pray that there isn't a data exception (and be prepared to
roll back if there is), and then call GetChanges(). Not only is this
potentially a very messy scenario, but it is not event-driven.

DirtyChecker circumvents this by finding all the databindings for a given
System.Windows.Forms.CurrencyManager, hooking into various control events,
and raising an event when the dirty state of any of the controls changes."

The class (and a small sample project that uses the class) is located
here:

http://fawx.com/code/DirtyChecker.zip

Erik
 
A

Aaron A. Anderson

Very interesting, thanks for sharing!

PS: Think this can be modified to be made into a component that implements
IExtenderProvider?
 

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