[dba-VB] C# dirty handler

Charlotte Foust cfoust at infostatsystems.com
Tue Mar 30 10:22:08 CDT 2010


John,

We use an IsValid method on each of our forms/subforms and call that before allowing the user to leave a form.  The routine tests against any rules we've established to determine whether this is a valid record, and if it is, it calls an update routine and returns a true value to the calling object.  If you use the bindingcontext of the datasource and EndCurrentEdit, you can reliably call HasChanges and if so update the datasource.

With a grid, the IsValid method is called from the validating event of the grid, so it is triggered when the grid loses focus or adds or changes a row.

Charlotte Foust

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Saturday, March 27, 2010 8:04 AM
To: VBA
Subject: [dba-VB] C# dirty handler

What do you guys use to handle dirty records?  I am migrating my billing program to C# and so have a 
ton of forms for the little list tables.  If I forget to click save after making a change the change 
is not saved back to the database.  Not cool.

I have found a couple of pieces of code that do the check and at least tell you that the form is dirty.

http://crfdesign.net/crf-design/quick-and-dirty-dirty-checking-for-windows-form-c
http://www.mishainthecloud.com/2009/07/simple-dirty-tracking-for-winforms-in-c.html

Either looks fine, but I just thought I'd check and see if y'all had any favorites or any words of 
wisdom.

Also does this kind of code handle grid controls correctly?  IOW if the form simply hosts a grid, 
will that grid report dirty and be picked up by this kind of code?

-- 
John W. Colby
www.ColbyConsulting.com
_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com





More information about the dba-VB mailing list